Commit ad5949c2 authored by Mathieu Pouit's avatar Mathieu Pouit

module2, suppression Anglais

parent 38cf88a4
*~
\ No newline at end of file
# -- coding: utf-8-unix; mode:org; fill-column: 100; mode: auto-fill; -*-
#+TITLE: Introduction à Markdown
#+DATE: June, 2018
#+LANG: fr
#+STARTUP: overview indent
#+OPTIONS: num:nil toc:t
Voici un aperçu rapide de la syntaxe Markdown repris d'une
[[https://guides.github.com/features/mastering-markdown/][présentation de GitHub]] ainsi que de celles d'[[http://csrgxtu.github.io/2015/03/20/Writing-Mathematic-Fomulars-in-Markdown/][Archer Reilly]].
* Table des matières :TOC:
- [[#syntaxe][Syntaxe]]
- [[#headers][Headers]]
- [[#emphasis][Emphasis]]
- [[#lists][Lists]]
- [[#images][Images]]
- [[#links][Links]]
- [[#blockquotes][Blockquotes]]
- [[#inline-code][Inline code]]
- [[#écrire-des-maths][Écrire des Maths]]
- [[#lettres-grecques][Lettres grecques]]
- [[#fonctions-et-opérateurs][Fonctions et opérateurs]]
- [[#exposants-et-indices][Exposants et indices]]
- [[#fractions-coefficients-binomiaux-racines-][Fractions, coefficients binomiaux, racines...]]
- [[#sommes-et-intégrales][Sommes et intégrales]]
- [[#déguisements][Déguisements]]
- [[#autour-de-markdown][Autour de Markdown]]
* Syntaxe
** Headers
#+BEGIN_EXAMPLE
# This is an <h1> tag
## This is an <h2> tag
###### This is an <h6> tag
#+END_EXAMPLE
** Emphasis
#+BEGIN_EXAMPLE
*This text will be italic*
_This will also be italic_
**This text will be bold**
__This will also be bold__
_You **can** combine them_
#+END_EXAMPLE
** Lists
*** Unordered
#+BEGIN_EXAMPLE
- Item 1
- Item 2
- Item 2a
- Item 2b
#+END_EXAMPLE
*** Ordered
#+BEGIN_EXAMPLE
1. Item 1
2. Item 2
3. Item 3
1. Item 3a
2. Item 3b
#+END_EXAMPLE
** Images
#+BEGIN_EXAMPLE
![GitHub Logo](/images/logo.png)
Format: ![Alt Text](url)
#+END_EXAMPLE
** Links
#+BEGIN_EXAMPLE
http://github.com - automatic!
[GitHub](http://github.com)
#+END_EXAMPLE
** Blockquotes
#+BEGIN_EXAMPLE
As Kanye West said:
> We're living the future so
> the present is our past.
#+END_EXAMPLE
** Inline code
#+BEGIN_EXAMPLE
To print some text with Python, you should use the `print()` function.
```
print("Hello world!")
```
#+END_EXAMPLE
* Écrire des Maths
Il est possible d'écrire des formules en Markdown, soit en mode *inline*
soit en mode *displayed formulas*. Dans le premier cas, les formules
sont incluses directement à l'intérieur du paragraphe courant alors
que dans le second, elles apparaissent centrées et mises en exergue.
Le formatage de la formule est légèrement différent dans les deux cas
car pour qu'une formule s'affiche joliment sur une seule ligne, il
faut la "tasser" un peu plus que lorsqu'elle est mise en valeur.
Pour écrire une formule en mode *inline*, il faut la délimiter par un =$=
(du coup, pour écrire le symbole dollar, il faut le préfixer par un
backslash, comme ceci : =\$=) alors que pour écrire en mode *displayed*, il
faut la délimiter par un =$$=. Un petit exemple valant mieux qu'un long
discours, voici concrètement comment cela fonctionne :
#+BEGIN_EXAMPLE
Cette expression $\sum_{i=1}^n X_i$ est inlinée.
#+END_EXAMPLE
Cette expression $\sum_{i=1}^n X_i$ est inlinée.
#+BEGIN_EXAMPLE
Cette expression est mise en valeur :
$$\sum_{i=1}^n X_i$$
#+END_EXAMPLE
Cette expression est mise en valeur :
$$\sum_{i=1}^n X_i$$
Nous vous présentons par la suite une sélection de symboles et de
commandes courants. En fait, à peu près tout ce qui est classique
dans le langage LaTeX peut être utilisé pourvu que vous délimitiez
bien avec un =$=. Pour d'autres exemples plus complets jetez un coup
d'œil à ces [[http://www.statpower.net/Content/310/R%20Stuff/SampleMarkdown.html][exemples de James H. Steiger]].
** Lettres grecques
| Symbole | Commande |
|---------+----------|
| $\alpha$ | =$\alpha$= |
| $\beta$ | =$\beta$= |
| $\gamma$ | =$\gamma$= |
| $\Gamma$ | =$\Gamma$= |
| $\pi$ | =$\pi$= |
** Fonctions et opérateurs
| Symbole | Commande |
|---------+----------|
| $\cos$ | =$\cos$= |
| $\sin$ | =$\sin$= |
| $\lim$ | =$\lim$= |
| $\exp$ | =$\exp$= |
| $\to$ | =$\to$= |
| $\in$ | =$\in$= |
| $\forall$ | =$\forall$= |
| $\exists$ | =$\exists$= |
| $\equiv$ | =$\equiv$= |
| $\sim$ | =$\sim$= |
| $\approx$ | =$\approx$= |
| $\times$ | =$\times$= |
| $\le$ | =$\le$= |
| $\ge$ | =$\ge$= |
** Exposants et indices
| Symbole | Commande |
|---------+-----------|
| $k_{n+1}$ | =$k_{n+1}$= |
| $n^2$ | =$n^2$= |
| $k_n^2$ | =$k_n^2$= |
** Fractions, coefficients binomiaux, racines...
| Symbole | Commande |
|-----------------------------+-----------------------------|
| $\frac{4z^3}{16}$ | =$\frac{4z^3}{16}$= |
| $\frac{n!}{k!(n-k)!}$ | =$\frac{n!}{k!(n-k)!}$= |
| $\binom{n}{k}$ | =$\binom{n}{k}$= |
| $\frac{\frac{x}{1}}{x - y}$ | =$\frac{\frac{x}{1}}{x - y}$= |
| $^3/_7$ | =$^3/_7$= |
| $\sqrt{k}$ | =$\sqrt{k}$= |
| $\sqrt[n]{k}$ | =$\sqrt[n]{k}$= |
** Sommes et intégrales
| Symbole | Commande |
|---------------------------------+--------------------------------------|
| $\sum_{i=1}^{10} t_i$ | =$\sum_{i=1}^{10} t_i$= |
| $\int_0^\infty \mathrm{e}^{-x}\,\mathrm{d}x$ | =$\int_0^\infty \mathrm{e}^{-x}\,\mathrm{d}x$= |
** Déguisements
| Symbole | Commande |
|-----------------------+-----------------------|
| $\hat{a}$ | =$\hat{a}$= |
| $\bar{a}$ | =$\bar{a}$= |
| $\dot{a}$ | =$\dot{a}$= |
| $\ddot{a}$ | =$\ddot{a}$= |
| $\overrightarrow{AB}$ | =$\overrightarrow{AB}$= |
* Autour de =Markdown=
Tout d'abord, pour aller plus loin avec =Markdown= et ses extensions / ramifications :
- Le didacticiel « [[https://enacit1.epfl.ch/markdown-pandoc/][Élaboration et conversion de documents avec Markdown et Pandoc]] » de Jean-Daniel Bonjour (EPFL), précis, complet, concis, en français ; un vrai bonheur !
- L'article [[https://en.wikipedia.org/wiki/Markdown#Example][Markdown]] de wikipedia en anglais contient un bon pense-bête sur la syntaxe =Markdown=.
- GitHub propose un court et efficace didacticiel (en anglais) : [[https://guides.github.com/features/mastering-markdown/][Mastering Markdown]].
Comme nous l'illustrons dans le « film d'écran » (/screencast/), l'éditeur de texte des dépôts =GitHub=
et =GitLab= permet d'interpréter / transformer à la demande un fichier =Markdown= en un fichier
=html=. C'est à la fois agréable et pratique, mais ce n'est pas une solution pour une utilisation
quotidienne de =Markdown=, pour cela, il est plus efficace d'éditer son texte, avec un éditeur de
texte, sur son ordinateur, avant de « l'exporter » dans un format comme =html=, =pdf=, =docx=, =epub=,
etc. Il existe des éditeurs plus ou moins spécialisés pour =Markdown=, certains sont indiqués sur la
page [[https://github.com/jgm/pandoc/wiki/Pandoc-Extras#editors][Editors]] du site de =Pandoc=, mais nous préconisons clairement l'emploi d'un éditeur de texte
« généraliste » capable de reconnaître la syntaxe =Markdown=. Nous en avons indiqué en début de
séquence et on pourra trouver des informations complémentaires dans la section
[[https://enacit1.epfl.ch/markdown-pandoc/#editeurs_markdown][Quelques éditeurs adaptés à l'édition Markdown]] du didacticiel de Jean-Daniel Bonjour.
Pour convertir un fichier =Markdown= en un format « arbitraire », la solution à ce jour la plus
complète est [[http://pandoc.org/][Pandoc]], logiciel développé par John MacFarlane, un philosophe de Berkeley (le site
[[https://github.com/jgm/pandoc][GitHub]]). En plus du site de =Pandoc=, le didacticiel de J.-D. Bonjour donne de nombreuses explications
sur comment installer et utiliser =Pandoc= dans la section [[https://enacit1.epfl.ch/markdown-pandoc/#commande_pandoc][Utilisation du convertisseur Pandoc]]. Comme
=Pandoc= -- écrit en Haskell -- peut être parfois un peu difficile à installer, nous indiquons
maintenant quelques solutions alternatives :
- Des sites comme [[http://www.markdowntopdf.com/]] et [[http://markdown2pdf.com/]] permettent de convertir
en ligne un fichier =Markdown= en un fichier =pdf=.
- Le projet [[http://commonmark.org/][CommonMark]] propose, en plus d'une spécification plus rigoureuse de la syntaxe =Markdown=,
des convertisseurs =Markdown= → =html= / =LaTeX= (et plus) écrits en =C= et en =JavaScript=
([[https://github.com/CommonMark/CommonMark]]).
- Le site de [[https://daringfireball.net/projects/markdown/][John Gruber]], le créateur de =Markdown=, fournit un convertisseur =Markdown= → =html= écrit en
=Perl=.
- [[http://fletcherpenney.net/multimarkdown/][MultiMarkdown]] est une autre extension de =Markdown= qui vient avec son convertisseur =Markdown= → =html=
écrit en =C=.
- [[https://github.com/joeyespo/grip][grip]] est un serveur écrit en =Python= qui permet de convertir et visualiser à la volée des fichiers
=Markdown= avec son navigateur (très utile pour éviter d'avoir à faire des « commits » en grande
quantité lorsqu'on écrit de tels fichiers pour un dépôt =GitHub= ou =GitLab=).
La conversion en =pdf= passe toujours par [[https://fr.wikipedia.org/wiki/LaTeX][LaTeX]] ce qui nécessite d'avoir une version complète et à
jour de ce logiciel sur sa machine.
Dans la petite démonstration, nous montrons comment générer un fichier =docx= à partir d'un fichier =md=
avec =Pandoc= et nous soulignons qu'il est alors possible d'utiliser un traitement de texte comme
=LibreOffice= pour modifier le fichier obtenu. Il est clair que si des modifications sont apportées au
=docx= elles ne seront pas (automatiquement) propagées au =md=. Il faudra utiliser =Pandoc= pour cela et
effectuer une conversion de =docx= vers =md= (et seuls les éléments du format =docx= qui existent en =md=
seront conservés).
Une stratégie qui est souvent employée et qui fonctionne bien en pratique consiste à faire le gros
du travail de rédaction d'un article ou d'un mémoire en =Markdown=. La rédaction terminée, le fichier
est exporté au format =docx= (ou =LaTeX=) et des ajustements de mise en page sont alors effectués avec
un logiciel de traitement de texte (ou un éditeur =LaTeX=).
---
title: "Your title"
author: "Your name"
date: "Today's date"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## Some explanations
This is an R Markdown document that you can easily export to HTML, PDF, and MS Word formats. For more information on R Markdown, see <http://rmarkdown.rstudio.com>.
When you click on the button **Knit**, the document will be compiled in order to re-execute the R code and to include the results into the final document. As we have shown in the video, R code is inserted as follows:
```{r cars}
summary(cars)
```
It is also straightforward to include figures. For example:
```{r pressure, echo=FALSE}
plot(pressure)
```
Note the parameter `echo = FALSE` that indicates that the code will not appear in the final version of the document. We recommend not to use this parameter in the context of this MOOC, because we want your data analyses to be perfectly transparent and reproducible.
Since the results are not stored in Rmd files, you should generate an HTML or PDF version of your exercises and commit them. Otherwise reading and checking your analysis will be difficult for anyone else but you.
Now it's your turn! You can delete all this information and replace it by your computational document.
#+TITLE: Your title
#+AUTHOR: Your name
#+DATE: Today's date
#+LANGUAGE: en
# #+PROPERTY: header-args :eval never-export
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="http://www.pirilampo.org/styles/readtheorg/css/htmlize.css"/>
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="http://www.pirilampo.org/styles/readtheorg/css/readtheorg.css"/>
#+HTML_HEAD: <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
#+HTML_HEAD: <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
#+HTML_HEAD: <script type="text/javascript" src="http://www.pirilampo.org/styles/lib/js/jquery.stickytableheaders.js"></script>
#+HTML_HEAD: <script type="text/javascript" src="http://www.pirilampo.org/styles/readtheorg/js/readtheorg.js"></script>
* Some explanations
This is an org-mode document with code examples in R. Once opened in
Emacs, this document can easily be exported to HTML, PDF, and Office
formats. For more information on org-mode, see
https://orgmode.org/guide/.
When you type the shortcut =C-c C-e h o=, this document will be
exported as HTML. All the code in it will be re-executed, and the
results will be retrieved and included into the exported document. If
you do not want to re-execute all code each time, you can delete the #
and the space before ~#+PROPERTY:~ in the header of this document.
Like we showed in the video, R code is included as follows (and is
exxecuted by typing ~C-c C-c~):
#+begin_src R :results output :exports both
print("Hello world!")
#+end_src
#+RESULTS:
: [1] "Hello world!"
And now the same but in an R session. This is the most frequent
situation, because R is really an interactive language. With a
session, R's state, i.e. the values of all the variables, remains
persistent from one code block to the next. The code is still executed
using ~C-c C-c~.
#+begin_src R :results output :session *R* :exports both
summary(cars)
#+end_src
#+RESULTS:
: speed dist
: Min. : 4.0 Min. : 2.00
: 1st Qu.:12.0 1st Qu.: 26.00
: Median :15.0 Median : 36.00
: Mean :15.4 Mean : 42.98
: 3rd Qu.:19.0 3rd Qu.: 56.00
: Max. :25.0 Max. :120.00
Finally, an example for graphical output:
#+begin_src R :results output graphics :file "./cars.png" :exports results :width 600 :height 400 :session *R*
plot(cars)
#+end_src
#+RESULTS:
[[file:./cars.png]]
Note the parameter ~:exports results~, which indicates that the code
will not appear in the exported document. We recommend that in the
context of this MOOC, you always leave this parameter setting as
~:exports both~, because we want your analyses to be perfectly
transparent and reproducible.
Watch out: the figure generated by the code block is /not/ stored in
the org document. It's a plain file, here named ~cars.png~. You have
to commit it explicitly if you want your analysis to be legible and
understandable on GitLab.
Finally, don't forget that we provide in the resource section of this
MOOC a configuration with a few keyboard shortcuts that allow you to
quickly create code blocks in R by typing ~<r~ or ~<R~ followed by
~Tab~.
Now it's your turn! You can delete all this information and replace it
by your computational document.
#+TITLE: Your title
#+AUTHOR: Your name
#+DATE: Today's date
#+LANGUAGE: en
# #+PROPERTY: header-args :eval never-export
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="http://www.pirilampo.org/styles/readtheorg/css/htmlize.css"/>
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="http://www.pirilampo.org/styles/readtheorg/css/readtheorg.css"/>
#+HTML_HEAD: <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
#+HTML_HEAD: <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
#+HTML_HEAD: <script type="text/javascript" src="http://www.pirilampo.org/styles/lib/js/jquery.stickytableheaders.js"></script>
#+HTML_HEAD: <script type="text/javascript" src="http://www.pirilampo.org/styles/readtheorg/js/readtheorg.js"></script>
* Some explanations
This is an org-mode document with code examples in R. Once opened in
Emacs, this document can easily be exported to HTML, PDF, and Office
formats. For more information on org-mode, see
https://orgmode.org/guide/.
When you type the shortcut =C-c C-e h o=, this document will be
exported as HTML. All the code in it will be re-executed, and the
results will be retrieved and included into the exported document. If
you do not want to re-execute all code each time, you can delete the #
and the space before ~#+PROPERTY:~ in the header of this document.
Like we showed in the video, Python code is included as follows (and
is exxecuted by typing ~C-c C-c~):
#+begin_src python :results output :exports both
print("Hello world!")
#+end_src
#+RESULTS:
: Hello world!
And now the same but in an Python session. With a session, Python's
state, i.e. the values of all the variables, remains persistent from
one code block to the next. The code is still executed using ~C-c
C-c~.
#+begin_src python :results output :session :exports both
import numpy
x=numpy.linspace(-15,15)
print(x)
#+end_src
#+RESULTS:
#+begin_example
[-15. -14.3877551 -13.7755102 -13.16326531 -12.55102041
-11.93877551 -11.32653061 -10.71428571 -10.10204082 -9.48979592
-8.87755102 -8.26530612 -7.65306122 -7.04081633 -6.42857143
-5.81632653 -5.20408163 -4.59183673 -3.97959184 -3.36734694
-2.75510204 -2.14285714 -1.53061224 -0.91836735 -0.30612245
0.30612245 0.91836735 1.53061224 2.14285714 2.75510204
3.36734694 3.97959184 4.59183673 5.20408163 5.81632653
6.42857143 7.04081633 7.65306122 8.26530612 8.87755102
9.48979592 10.10204082 10.71428571 11.32653061 11.93877551
12.55102041 13.16326531 13.7755102 14.3877551 15. ]
#+end_example
Finally, an example for graphical output:
#+begin_src python :results output file :session :var matplot_lib_filename="./cosxsx.png" :exports results
import matplotlib.pyplot as plt
plt.figure(figsize=(10,5))
plt.plot(x,numpy.cos(x)/x)
plt.tight_layout()
plt.savefig(matplot_lib_filename)
print(matplot_lib_filename)
#+end_src
#+RESULTS:
[[file:./cosxsx.png]]
Note the parameter ~:exports results~, which indicates that the code
will not appear in the exported document. We recommend that in the
context of this MOOC, you always leave this parameter setting as
~:exports both~, because we want your analyses to be perfectly
transparent and reproducible.
Watch out: the figure generated by the code block is /not/ stored in
the org document. It's a plain file, here named ~cosxsx.png~. You have
to commit it explicitly if you want your analysis to be legible and
understandable on GitLab.
Finally, don't forget that we provide in the resource section of this
MOOC a configuration with a few keyboard shortcuts that allow you to
quickly create code blocks in Python by typing ~<p~, ~<P~ or ~<PP~
followed by ~Tab~.
Now it's your turn! You can delete all this information and replace it
by your computational document.
......@@ -64,7 +64,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Mais calculé avec la méthode des aiguilles de Buffon, on obtiendrait"
"Mais calculé avec la **méthode** des [aiguilles de Buffon](https://fr.wikipedia.org/wiki/Aiguille_de_Buffon), on obtiendrait comme **approximation**"
]
},
{
......
#+TITLE: Your title
#+AUTHOR: Your name
#+DATE: Today's date
#+LANGUAGE: en
# #+PROPERTY: header-args :eval never-export
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="http://www.pirilampo.org/styles/readtheorg/css/htmlize.css"/>
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="http://www.pirilampo.org/styles/readtheorg/css/readtheorg.css"/>
#+HTML_HEAD: <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
#+HTML_HEAD: <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
#+HTML_HEAD: <script type="text/javascript" src="http://www.pirilampo.org/styles/lib/js/jquery.stickytableheaders.js"></script>
#+HTML_HEAD: <script type="text/javascript" src="http://www.pirilampo.org/styles/readtheorg/js/readtheorg.js"></script>
* Some explanations
This is an org-mode document with code examples in R. Once opened in
Emacs, this document can easily be exported to HTML, PDF, and Office
formats. For more information on org-mode, see
https://orgmode.org/guide/.
When you type the shortcut =C-c C-e h o=, this document will be
exported as HTML. All the code in it will be re-executed, and the
results will be retrieved and included into the exported document. If
you do not want to re-execute all code each time, you can delete the #
and the space before ~#+PROPERTY:~ in the header of this document.
Like we showed in the video, R code is included as follows (and is
exxecuted by typing ~C-c C-c~):
#+begin_src R :results output :exports both
print("Hello world!")
#+end_src
#+RESULTS:
: [1] "Hello world!"
And now the same but in an R session. This is the most frequent
situation, because R is really an interactive language. With a
session, R's state, i.e. the values of all the variables, remains
persistent from one code block to the next. The code is still executed
using ~C-c C-c~.
#+begin_src R :results output :session *R* :exports both
summary(cars)
#+end_src
#+RESULTS:
: speed dist
: Min. : 4.0 Min. : 2.00
: 1st Qu.:12.0 1st Qu.: 26.00
: Median :15.0 Median : 36.00
: Mean :15.4 Mean : 42.98
: 3rd Qu.:19.0 3rd Qu.: 56.00
: Max. :25.0 Max. :120.00
Finally, an example for graphical output:
#+begin_src R :results output graphics :file "./cars.png" :exports results :width 600 :height 400 :session *R*
plot(cars)
#+end_src
#+RESULTS:
[[file:./cars.png]]
Note the parameter ~:exports results~, which indicates that the code
will not appear in the exported document. We recommend that in the
context of this MOOC, you always leave this parameter setting as
~:exports both~, because we want your analyses to be perfectly
transparent and reproducible.
Watch out: the figure generated by the code block is /not/ stored in
the org document. It's a plain file, here named ~cars.png~. You have
to commit it explicitly if you want your analysis to be legible and
understandable on GitLab.
Finally, don't forget that we provide in the resource section of this
MOOC a configuration with a few keyboard shortcuts that allow you to
quickly create code blocks in R by typing ~<r~ or ~<R~ followed by
~Tab~.
Now it's your turn! You can delete all this information and replace it
by your computational document.
---
title: "Your title"
author: "Your name"
date: "Today's date"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## Some explanations
This is an R Markdown document that you can easily export to HTML, PDF, and MS Word formats. For more information on R Markdown, see <http://rmarkdown.rstudio.com>.
When you click on the button **Knit**, the document will be compiled in order to re-execute the R code and to include the results into the final document. As we have shown in the video, R code is inserted as follows:
```{r cars}
summary(cars)
```
It is also straightforward to include figures. For example:
```{r pressure, echo=FALSE}
plot(pressure)
```
Note the parameter `echo = FALSE` that indicates that the code will not appear in the final version of the document. We recommend not to use this parameter in the context of this MOOC, because we want your data analyses to be perfectly transparent and reproducible.
Since the results are not stored in Rmd files, you should generate an HTML or PDF version of your exercises and commit them. Otherwise reading and checking your analysis will be difficult for anyone else but you.
Now it's your turn! You can delete all this information and replace it by your computational document.
{
"cells": [],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
#+TITLE: Your title
#+AUTHOR: Your name
#+DATE: Today's date
#+LANGUAGE: en
# #+PROPERTY: header-args :eval never-export
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="http://www.pirilampo.org/styles/readtheorg/css/htmlize.css"/>
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="http://www.pirilampo.org/styles/readtheorg/css/readtheorg.css"/>
#+HTML_HEAD: <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
#+HTML_HEAD: <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
#+HTML_HEAD: <script type="text/javascript" src="http://www.pirilampo.org/styles/lib/js/jquery.stickytableheaders.js"></script>
#+HTML_HEAD: <script type="text/javascript" src="http://www.pirilampo.org/styles/readtheorg/js/readtheorg.js"></script>
* Some explanations
This is an org-mode document with code examples in R. Once opened in
Emacs, this document can easily be exported to HTML, PDF, and Office
formats. For more information on org-mode, see
https://orgmode.org/guide/.
When you type the shortcut =C-c C-e h o=, this document will be
exported as HTML. All the code in it will be re-executed, and the
results will be retrieved and included into the exported document. If
you do not want to re-execute all code each time, you can delete the #
and the space before ~#+PROPERTY:~ in the header of this document.
Like we showed in the video, Python code is included as follows (and
is exxecuted by typing ~C-c C-c~):
#+begin_src python :results output :exports both
print("Hello world!")
#+end_src
#+RESULTS:
: Hello world!
And now the same but in an Python session. With a session, Python's
state, i.e. the values of all the variables, remains persistent from
one code block to the next. The code is still executed using ~C-c
C-c~.
#+begin_src python :results output :session :exports both
import numpy
x=numpy.linspace(-15,15)
print(x)
#+end_src
#+RESULTS:
#+begin_example
[-15. -14.3877551 -13.7755102 -13.16326531 -12.55102041
-11.93877551 -11.32653061 -10.71428571 -10.10204082 -9.48979592
-8.87755102 -8.26530612 -7.65306122 -7.04081633 -6.42857143
-5.81632653 -5.20408163 -4.59183673 -3.97959184 -3.36734694
-2.75510204 -2.14285714 -1.53061224 -0.91836735 -0.30612245
0.30612245 0.91836735 1.53061224 2.14285714 2.75510204
3.36734694 3.97959184 4.59183673 5.20408163 5.81632653
6.42857143 7.04081633 7.65306122 8.26530612 8.87755102
9.48979592 10.10204082 10.71428571 11.32653061 11.93877551
12.55102041 13.16326531 13.7755102 14.3877551 15. ]
#+end_example
Finally, an example for graphical output:
#+begin_src python :results output file :session :var matplot_lib_filename="./cosxsx.png" :exports results
import matplotlib.pyplot as plt
plt.figure(figsize=(10,5))
plt.plot(x,numpy.cos(x)/x)
plt.tight_layout()
plt.savefig(matplot_lib_filename)
print(matplot_lib_filename)
#+end_src
#+RESULTS:
[[file:./cosxsx.png]]
Note the parameter ~:exports results~, which indicates that the code
will not appear in the exported document. We recommend that in the
context of this MOOC, you always leave this parameter setting as
~:exports both~, because we want your analyses to be perfectly
transparent and reproducible.
Watch out: the figure generated by the code block is /not/ stored in
the org document. It's a plain file, here named ~cosxsx.png~. You have
to commit it explicitly if you want your analysis to be legible and
understandable on GitLab.
Finally, don't forget that we provide in the resource section of this
MOOC a configuration with a few keyboard shortcuts that allow you to
quickly create code blocks in Python by typing ~<p~, ~<P~ or ~<PP~
followed by ~Tab~.
Now it's your turn! You can delete all this information and replace it
by your computational document.
#+TITLE: Your title
#+AUTHOR: Your name
#+DATE: Today's date
#+LANGUAGE: en
# #+PROPERTY: header-args :eval never-export
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="http://www.pirilampo.org/styles/readtheorg/css/htmlize.css"/>
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="http://www.pirilampo.org/styles/readtheorg/css/readtheorg.css"/>
#+HTML_HEAD: <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
#+HTML_HEAD: <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
#+HTML_HEAD: <script type="text/javascript" src="http://www.pirilampo.org/styles/lib/js/jquery.stickytableheaders.js"></script>
#+HTML_HEAD: <script type="text/javascript" src="http://www.pirilampo.org/styles/readtheorg/js/readtheorg.js"></script>
* Some explanations
This is an org-mode document with code examples in R. Once opened in
Emacs, this document can easily be exported to HTML, PDF, and Office
formats. For more information on org-mode, see
https://orgmode.org/guide/.
When you type the shortcut =C-c C-e h o=, this document will be
exported as HTML. All the code in it will be re-executed, and the
results will be retrieved and included into the exported document. If
you do not want to re-execute all code each time, you can delete the #
and the space before ~#+PROPERTY:~ in the header of this document.
Like we showed in the video, R code is included as follows (and is
exxecuted by typing ~C-c C-c~):
#+begin_src R :results output :exports both
print("Hello world!")
#+end_src
#+RESULTS:
: [1] "Hello world!"
And now the same but in an R session. This is the most frequent
situation, because R is really an interactive language. With a
session, R's state, i.e. the values of all the variables, remains
persistent from one code block to the next. The code is still executed
using ~C-c C-c~.
#+begin_src R :results output :session *R* :exports both
summary(cars)
#+end_src
#+RESULTS:
: speed dist
: Min. : 4.0 Min. : 2.00
: 1st Qu.:12.0 1st Qu.: 26.00
: Median :15.0 Median : 36.00
: Mean :15.4 Mean : 42.98
: 3rd Qu.:19.0 3rd Qu.: 56.00
: Max. :25.0 Max. :120.00
Finally, an example for graphical output:
#+begin_src R :results output graphics :file "./cars.png" :exports results :width 600 :height 400 :session *R*
plot(cars)
#+end_src
#+RESULTS:
[[file:./cars.png]]
Note the parameter ~:exports results~, which indicates that the code
will not appear in the exported document. We recommend that in the
context of this MOOC, you always leave this parameter setting as
~:exports both~, because we want your analyses to be perfectly
transparent and reproducible.
Watch out: the figure generated by the code block is /not/ stored in
the org document. It's a plain file, here named ~cars.png~. You have
to commit it explicitly if you want your analysis to be legible and
understandable on GitLab.
Finally, don't forget that we provide in the resource section of this
MOOC a configuration with a few keyboard shortcuts that allow you to
quickly create code blocks in R by typing ~<r~ or ~<R~ followed by
~Tab~.
Now it's your turn! You can delete all this information and replace it
by your computational document.
---
title: "Your title"
author: "Your name"
date: "Today's date"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## Some explanations
This is an R Markdown document that you can easily export to HTML, PDF, and MS Word formats. For more information on R Markdown, see <http://rmarkdown.rstudio.com>.
When you click on the button **Knit**, the document will be compiled in order to re-execute the R code and to include the results into the final document. As we have shown in the video, R code is inserted as follows:
```{r cars}
summary(cars)
```
It is also straightforward to include figures. For example:
```{r pressure, echo=FALSE}
plot(pressure)
```
Note the parameter `echo = FALSE` that indicates that the code will not appear in the final version of the document. We recommend not to use this parameter in the context of this MOOC, because we want your data analyses to be perfectly transparent and reproducible.
Since the results are not stored in Rmd files, you should generate an HTML or PDF version of your exercises and commit them. Otherwise reading and checking your analysis will be difficult for anyone else but you.
Now it's your turn! You can delete all this information and replace it by your computational document.
{
"cells": [],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
#+TITLE: Your title
#+AUTHOR: Your name
#+DATE: Today's date
#+LANGUAGE: en
# #+PROPERTY: header-args :eval never-export
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="http://www.pirilampo.org/styles/readtheorg/css/htmlize.css"/>
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="http://www.pirilampo.org/styles/readtheorg/css/readtheorg.css"/>
#+HTML_HEAD: <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
#+HTML_HEAD: <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
#+HTML_HEAD: <script type="text/javascript" src="http://www.pirilampo.org/styles/lib/js/jquery.stickytableheaders.js"></script>
#+HTML_HEAD: <script type="text/javascript" src="http://www.pirilampo.org/styles/readtheorg/js/readtheorg.js"></script>
* Some explanations
This is an org-mode document with code examples in R. Once opened in
Emacs, this document can easily be exported to HTML, PDF, and Office
formats. For more information on org-mode, see
https://orgmode.org/guide/.
When you type the shortcut =C-c C-e h o=, this document will be
exported as HTML. All the code in it will be re-executed, and the
results will be retrieved and included into the exported document. If
you do not want to re-execute all code each time, you can delete the #
and the space before ~#+PROPERTY:~ in the header of this document.
Like we showed in the video, Python code is included as follows (and
is exxecuted by typing ~C-c C-c~):
#+begin_src python :results output :exports both
print("Hello world!")
#+end_src
#+RESULTS:
: Hello world!
And now the same but in an Python session. With a session, Python's
state, i.e. the values of all the variables, remains persistent from
one code block to the next. The code is still executed using ~C-c
C-c~.
#+begin_src python :results output :session :exports both
import numpy
x=numpy.linspace(-15,15)
print(x)
#+end_src
#+RESULTS:
#+begin_example
[-15. -14.3877551 -13.7755102 -13.16326531 -12.55102041
-11.93877551 -11.32653061 -10.71428571 -10.10204082 -9.48979592
-8.87755102 -8.26530612 -7.65306122 -7.04081633 -6.42857143
-5.81632653 -5.20408163 -4.59183673 -3.97959184 -3.36734694
-2.75510204 -2.14285714 -1.53061224 -0.91836735 -0.30612245
0.30612245 0.91836735 1.53061224 2.14285714 2.75510204
3.36734694 3.97959184 4.59183673 5.20408163 5.81632653
6.42857143 7.04081633 7.65306122 8.26530612 8.87755102
9.48979592 10.10204082 10.71428571 11.32653061 11.93877551
12.55102041 13.16326531 13.7755102 14.3877551 15. ]
#+end_example
Finally, an example for graphical output:
#+begin_src python :results output file :session :var matplot_lib_filename="./cosxsx.png" :exports results
import matplotlib.pyplot as plt
plt.figure(figsize=(10,5))
plt.plot(x,numpy.cos(x)/x)
plt.tight_layout()
plt.savefig(matplot_lib_filename)
print(matplot_lib_filename)
#+end_src
#+RESULTS:
[[file:./cosxsx.png]]
Note the parameter ~:exports results~, which indicates that the code
will not appear in the exported document. We recommend that in the
context of this MOOC, you always leave this parameter setting as
~:exports both~, because we want your analyses to be perfectly
transparent and reproducible.
Watch out: the figure generated by the code block is /not/ stored in
the org document. It's a plain file, here named ~cosxsx.png~. You have
to commit it explicitly if you want your analysis to be legible and
understandable on GitLab.
Finally, don't forget that we provide in the resource section of this
MOOC a configuration with a few keyboard shortcuts that allow you to
quickly create code blocks in Python by typing ~<p~, ~<P~ or ~<PP~
followed by ~Tab~.
Now it's your turn! You can delete all this information and replace it
by your computational document.
#+TITLE: Your title
#+AUTHOR: Your name
#+DATE: Today's date
#+LANGUAGE: en
# #+PROPERTY: header-args :eval never-export
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="http://www.pirilampo.org/styles/readtheorg/css/htmlize.css"/>
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="http://www.pirilampo.org/styles/readtheorg/css/readtheorg.css"/>
#+HTML_HEAD: <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
#+HTML_HEAD: <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
#+HTML_HEAD: <script type="text/javascript" src="http://www.pirilampo.org/styles/lib/js/jquery.stickytableheaders.js"></script>
#+HTML_HEAD: <script type="text/javascript" src="http://www.pirilampo.org/styles/readtheorg/js/readtheorg.js"></script>
* Some explanations
This is an org-mode document with code examples in R. Once opened in
Emacs, this document can easily be exported to HTML, PDF, and Office
formats. For more information on org-mode, see
https://orgmode.org/guide/.
When you type the shortcut =C-c C-e h o=, this document will be
exported as HTML. All the code in it will be re-executed, and the
results will be retrieved and included into the exported document. If
you do not want to re-execute all code each time, you can delete the #
and the space before ~#+PROPERTY:~ in the header of this document.
Like we showed in the video, R code is included as follows (and is
exxecuted by typing ~C-c C-c~):
#+begin_src R :results output :exports both
print("Hello world!")
#+end_src
#+RESULTS:
: [1] "Hello world!"
And now the same but in an R session. This is the most frequent
situation, because R is really an interactive language. With a
session, R's state, i.e. the values of all the variables, remains
persistent from one code block to the next. The code is still executed
using ~C-c C-c~.
#+begin_src R :results output :session *R* :exports both
summary(cars)
#+end_src
#+RESULTS:
: speed dist
: Min. : 4.0 Min. : 2.00
: 1st Qu.:12.0 1st Qu.: 26.00
: Median :15.0 Median : 36.00
: Mean :15.4 Mean : 42.98
: 3rd Qu.:19.0 3rd Qu.: 56.00
: Max. :25.0 Max. :120.00
Finally, an example for graphical output:
#+begin_src R :results output graphics :file "./cars.png" :exports results :width 600 :height 400 :session *R*
plot(cars)
#+end_src
#+RESULTS:
[[file:./cars.png]]
Note the parameter ~:exports results~, which indicates that the code
will not appear in the exported document. We recommend that in the
context of this MOOC, you always leave this parameter setting as
~:exports both~, because we want your analyses to be perfectly
transparent and reproducible.
Watch out: the figure generated by the code block is /not/ stored in
the org document. It's a plain file, here named ~cars.png~. You have
to commit it explicitly if you want your analysis to be legible and
understandable on GitLab.
Finally, don't forget that we provide in the resource section of this
MOOC a configuration with a few keyboard shortcuts that allow you to
quickly create code blocks in R by typing ~<r~ or ~<R~ followed by
~Tab~.
Now it's your turn! You can delete all this information and replace it
by your computational document.
---
title: "Your title"
author: "Your name"
date: "Today's date"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## Some explanations
This is an R Markdown document that you can easily export to HTML, PDF, and MS Word formats. For more information on R Markdown, see <http://rmarkdown.rstudio.com>.
When you click on the button **Knit**, the document will be compiled in order to re-execute the R code and to include the results into the final document. As we have shown in the video, R code is inserted as follows:
```{r cars}
summary(cars)
```
It is also straightforward to include figures. For example:
```{r pressure, echo=FALSE}
plot(pressure)
```
Note the parameter `echo = FALSE` that indicates that the code will not appear in the final version of the document. We recommend not to use this parameter in the context of this MOOC, because we want your data analyses to be perfectly transparent and reproducible.
Since the results are not stored in Rmd files, you should generate an HTML or PDF version of your exercises and commit them. Otherwise reading and checking your analysis will be difficult for anyone else but you.
Now it's your turn! You can delete all this information and replace it by your computational document.
{
"cells": [],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
#+TITLE: Your title
#+AUTHOR: Your name
#+DATE: Today's date
#+LANGUAGE: en
# #+PROPERTY: header-args :eval never-export
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="http://www.pirilampo.org/styles/readtheorg/css/htmlize.css"/>
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="http://www.pirilampo.org/styles/readtheorg/css/readtheorg.css"/>
#+HTML_HEAD: <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
#+HTML_HEAD: <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
#+HTML_HEAD: <script type="text/javascript" src="http://www.pirilampo.org/styles/lib/js/jquery.stickytableheaders.js"></script>
#+HTML_HEAD: <script type="text/javascript" src="http://www.pirilampo.org/styles/readtheorg/js/readtheorg.js"></script>
* Some explanations
This is an org-mode document with code examples in R. Once opened in
Emacs, this document can easily be exported to HTML, PDF, and Office
formats. For more information on org-mode, see
https://orgmode.org/guide/.
When you type the shortcut =C-c C-e h o=, this document will be
exported as HTML. All the code in it will be re-executed, and the
results will be retrieved and included into the exported document. If
you do not want to re-execute all code each time, you can delete the #
and the space before ~#+PROPERTY:~ in the header of this document.
Like we showed in the video, Python code is included as follows (and
is exxecuted by typing ~C-c C-c~):
#+begin_src python :results output :exports both
print("Hello world!")
#+end_src
#+RESULTS:
: Hello world!
And now the same but in an Python session. With a session, Python's
state, i.e. the values of all the variables, remains persistent from
one code block to the next. The code is still executed using ~C-c
C-c~.
#+begin_src python :results output :session :exports both
import numpy
x=numpy.linspace(-15,15)
print(x)
#+end_src
#+RESULTS:
#+begin_example
[-15. -14.3877551 -13.7755102 -13.16326531 -12.55102041
-11.93877551 -11.32653061 -10.71428571 -10.10204082 -9.48979592
-8.87755102 -8.26530612 -7.65306122 -7.04081633 -6.42857143
-5.81632653 -5.20408163 -4.59183673 -3.97959184 -3.36734694
-2.75510204 -2.14285714 -1.53061224 -0.91836735 -0.30612245
0.30612245 0.91836735 1.53061224 2.14285714 2.75510204
3.36734694 3.97959184 4.59183673 5.20408163 5.81632653
6.42857143 7.04081633 7.65306122 8.26530612 8.87755102
9.48979592 10.10204082 10.71428571 11.32653061 11.93877551
12.55102041 13.16326531 13.7755102 14.3877551 15. ]
#+end_example
Finally, an example for graphical output:
#+begin_src python :results output file :session :var matplot_lib_filename="./cosxsx.png" :exports results
import matplotlib.pyplot as plt
plt.figure(figsize=(10,5))
plt.plot(x,numpy.cos(x)/x)
plt.tight_layout()
plt.savefig(matplot_lib_filename)
print(matplot_lib_filename)
#+end_src
#+RESULTS:
[[file:./cosxsx.png]]
Note the parameter ~:exports results~, which indicates that the code
will not appear in the exported document. We recommend that in the
context of this MOOC, you always leave this parameter setting as
~:exports both~, because we want your analyses to be perfectly
transparent and reproducible.
Watch out: the figure generated by the code block is /not/ stored in
the org document. It's a plain file, here named ~cosxsx.png~. You have
to commit it explicitly if you want your analysis to be legible and
understandable on GitLab.
Finally, don't forget that we provide in the resource section of this
MOOC a configuration with a few keyboard shortcuts that allow you to
quickly create code blocks in Python by typing ~<p~, ~<P~ or ~<PP~
followed by ~Tab~.
Now it's your turn! You can delete all this information and replace it
by your computational document.
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Analysis of the risk of failure of the O-rings on the Challenger shuttle"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"On January 27, 1986, the day before the takeoff of the shuttle _Challenger_, had\n",
"a three-hour teleconference was held between \n",
"Morton Thiokol (the manufacturer of one of the engines) and NASA. The\n",
"discussion focused on the consequences of the\n",
"temperature at take-off of 31°F (just below\n",
"0°C) for the success of the flight and in particular on the performance of the\n",
"O-rings used in the engines. Indeed, no test\n",
"had been performed at this temperature.\n",
"\n",
"The following study takes up some of the analyses carried out that\n",
"night with the objective of assessing the potential influence of\n",
"the temperature and pressure to which the O-rings are subjected\n",
"on their probability of malfunction. Our starting point is \n",
"the results of the experiments carried out by NASA engineers\n",
"during the six years preceding the launch of the shuttle\n",
"Challenger."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Loading the data\n",
"We start by loading this data:"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<table>\n",
"<caption>A data.frame: 23 × 5</caption>\n",
"<thead>\n",
"\t<tr><th scope=col>Date</th><th scope=col>Count</th><th scope=col>Temperature</th><th scope=col>Pressure</th><th scope=col>Malfunction</th></tr>\n",
"\t<tr><th scope=col>&lt;fct&gt;</th><th scope=col>&lt;int&gt;</th><th scope=col>&lt;int&gt;</th><th scope=col>&lt;int&gt;</th><th scope=col>&lt;int&gt;</th></tr>\n",
"</thead>\n",
"<tbody>\n",
"\t<tr><td>4/12/81 </td><td>6</td><td>66</td><td> 50</td><td>0</td></tr>\n",
"\t<tr><td>11/12/81 </td><td>6</td><td>70</td><td> 50</td><td>1</td></tr>\n",
"\t<tr><td>3/22/82 </td><td>6</td><td>69</td><td> 50</td><td>0</td></tr>\n",
"\t<tr><td>11/11/82 </td><td>6</td><td>68</td><td> 50</td><td>0</td></tr>\n",
"\t<tr><td>4/04/83 </td><td>6</td><td>67</td><td> 50</td><td>0</td></tr>\n",
"\t<tr><td>6/18/82 </td><td>6</td><td>72</td><td> 50</td><td>0</td></tr>\n",
"\t<tr><td>8/30/83 </td><td>6</td><td>73</td><td>100</td><td>0</td></tr>\n",
"\t<tr><td>11/28/83 </td><td>6</td><td>70</td><td>100</td><td>0</td></tr>\n",
"\t<tr><td>2/03/84 </td><td>6</td><td>57</td><td>200</td><td>1</td></tr>\n",
"\t<tr><td>4/06/84 </td><td>6</td><td>63</td><td>200</td><td>1</td></tr>\n",
"\t<tr><td>8/30/84 </td><td>6</td><td>70</td><td>200</td><td>1</td></tr>\n",
"\t<tr><td>10/05/84 </td><td>6</td><td>78</td><td>200</td><td>0</td></tr>\n",
"\t<tr><td>11/08/84 </td><td>6</td><td>67</td><td>200</td><td>0</td></tr>\n",
"\t<tr><td>1/24/85 </td><td>6</td><td>53</td><td>200</td><td>2</td></tr>\n",
"\t<tr><td>4/12/85 </td><td>6</td><td>67</td><td>200</td><td>0</td></tr>\n",
"\t<tr><td>4/29/85 </td><td>6</td><td>75</td><td>200</td><td>0</td></tr>\n",
"\t<tr><td>6/17/85 </td><td>6</td><td>70</td><td>200</td><td>0</td></tr>\n",
"\t<tr><td>7/29/85</td><td>6</td><td>81</td><td>200</td><td>0</td></tr>\n",
"\t<tr><td>8/27/85 </td><td>6</td><td>76</td><td>200</td><td>0</td></tr>\n",
"\t<tr><td>10/03/85 </td><td>6</td><td>79</td><td>200</td><td>0</td></tr>\n",
"\t<tr><td>10/30/85 </td><td>6</td><td>75</td><td>200</td><td>2</td></tr>\n",
"\t<tr><td>11/26/85 </td><td>6</td><td>76</td><td>200</td><td>0</td></tr>\n",
"\t<tr><td>1/12/86 </td><td>6</td><td>58</td><td>200</td><td>1</td></tr>\n",
"</tbody>\n",
"</table>\n"
],
"text/latex": [
"A data.frame: 23 × 5\n",
"\\begin{tabular}{r|lllll}\n",
" Date & Count & Temperature & Pressure & Malfunction\\\\\n",
" <fct> & <int> & <int> & <int> & <int>\\\\\n",
"\\hline\n",
"\t 4/12/81 & 6 & 66 & 50 & 0\\\\\n",
"\t 11/12/81 & 6 & 70 & 50 & 1\\\\\n",
"\t 3/22/82 & 6 & 69 & 50 & 0\\\\\n",
"\t 11/11/82 & 6 & 68 & 50 & 0\\\\\n",
"\t 4/04/83 & 6 & 67 & 50 & 0\\\\\n",
"\t 6/18/82 & 6 & 72 & 50 & 0\\\\\n",
"\t 8/30/83 & 6 & 73 & 100 & 0\\\\\n",
"\t 11/28/83 & 6 & 70 & 100 & 0\\\\\n",
"\t 2/03/84 & 6 & 57 & 200 & 1\\\\\n",
"\t 4/06/84 & 6 & 63 & 200 & 1\\\\\n",
"\t 8/30/84 & 6 & 70 & 200 & 1\\\\\n",
"\t 10/05/84 & 6 & 78 & 200 & 0\\\\\n",
"\t 11/08/84 & 6 & 67 & 200 & 0\\\\\n",
"\t 1/24/85 & 6 & 53 & 200 & 2\\\\\n",
"\t 4/12/85 & 6 & 67 & 200 & 0\\\\\n",
"\t 4/29/85 & 6 & 75 & 200 & 0\\\\\n",
"\t 6/17/85 & 6 & 70 & 200 & 0\\\\\n",
"\t 7/29/85 & 6 & 81 & 200 & 0\\\\\n",
"\t 8/27/85 & 6 & 76 & 200 & 0\\\\\n",
"\t 10/03/85 & 6 & 79 & 200 & 0\\\\\n",
"\t 10/30/85 & 6 & 75 & 200 & 2\\\\\n",
"\t 11/26/85 & 6 & 76 & 200 & 0\\\\\n",
"\t 1/12/86 & 6 & 58 & 200 & 1\\\\\n",
"\\end{tabular}\n"
],
"text/markdown": [
"\n",
"A data.frame: 23 × 5\n",
"\n",
"| Date &lt;fct&gt; | Count &lt;int&gt; | Temperature &lt;int&gt; | Pressure &lt;int&gt; | Malfunction &lt;int&gt; |\n",
"|---|---|---|---|---|\n",
"| 4/12/81 | 6 | 66 | 50 | 0 |\n",
"| 11/12/81 | 6 | 70 | 50 | 1 |\n",
"| 3/22/82 | 6 | 69 | 50 | 0 |\n",
"| 11/11/82 | 6 | 68 | 50 | 0 |\n",
"| 4/04/83 | 6 | 67 | 50 | 0 |\n",
"| 6/18/82 | 6 | 72 | 50 | 0 |\n",
"| 8/30/83 | 6 | 73 | 100 | 0 |\n",
"| 11/28/83 | 6 | 70 | 100 | 0 |\n",
"| 2/03/84 | 6 | 57 | 200 | 1 |\n",
"| 4/06/84 | 6 | 63 | 200 | 1 |\n",
"| 8/30/84 | 6 | 70 | 200 | 1 |\n",
"| 10/05/84 | 6 | 78 | 200 | 0 |\n",
"| 11/08/84 | 6 | 67 | 200 | 0 |\n",
"| 1/24/85 | 6 | 53 | 200 | 2 |\n",
"| 4/12/85 | 6 | 67 | 200 | 0 |\n",
"| 4/29/85 | 6 | 75 | 200 | 0 |\n",
"| 6/17/85 | 6 | 70 | 200 | 0 |\n",
"| 7/29/85 | 6 | 81 | 200 | 0 |\n",
"| 8/27/85 | 6 | 76 | 200 | 0 |\n",
"| 10/03/85 | 6 | 79 | 200 | 0 |\n",
"| 10/30/85 | 6 | 75 | 200 | 2 |\n",
"| 11/26/85 | 6 | 76 | 200 | 0 |\n",
"| 1/12/86 | 6 | 58 | 200 | 1 |\n",
"\n"
],
"text/plain": [
" Date Count Temperature Pressure Malfunction\n",
"1 4/12/81 6 66 50 0 \n",
"2 11/12/81 6 70 50 1 \n",
"3 3/22/82 6 69 50 0 \n",
"4 11/11/82 6 68 50 0 \n",
"5 4/04/83 6 67 50 0 \n",
"6 6/18/82 6 72 50 0 \n",
"7 8/30/83 6 73 100 0 \n",
"8 11/28/83 6 70 100 0 \n",
"9 2/03/84 6 57 200 1 \n",
"10 4/06/84 6 63 200 1 \n",
"11 8/30/84 6 70 200 1 \n",
"12 10/05/84 6 78 200 0 \n",
"13 11/08/84 6 67 200 0 \n",
"14 1/24/85 6 53 200 2 \n",
"15 4/12/85 6 67 200 0 \n",
"16 4/29/85 6 75 200 0 \n",
"17 6/17/85 6 70 200 0 \n",
"18 7/29/85 6 81 200 0 \n",
"19 8/27/85 6 76 200 0 \n",
"20 10/03/85 6 79 200 0 \n",
"21 10/30/85 6 75 200 2 \n",
"22 11/26/85 6 76 200 0 \n",
"23 1/12/86 6 58 200 1 "
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"data = read.csv(\"shuttle.csv\",header=T)\n",
"data"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The data set shows us the date of each test, the number of O-rings (there are 6 on the main launcher), the temperature (in Fahrenheit) and pressure (in psi), and finally the number of identified malfunctions."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Graphical inspection\n",
"Flights without incidents do not provide any information\n",
"on the influence of temperature or pressure on malfunction.\n",
"We thus focus on the experiments in which at least one O-ring\n",
"was defective."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<table>\n",
"<caption>A data.frame: 7 × 5</caption>\n",
"<thead>\n",
"\t<tr><th></th><th scope=col>Date</th><th scope=col>Count</th><th scope=col>Temperature</th><th scope=col>Pressure</th><th scope=col>Malfunction</th></tr>\n",
"\t<tr><th></th><th scope=col>&lt;fct&gt;</th><th scope=col>&lt;int&gt;</th><th scope=col>&lt;int&gt;</th><th scope=col>&lt;int&gt;</th><th scope=col>&lt;int&gt;</th></tr>\n",
"</thead>\n",
"<tbody>\n",
"\t<tr><th scope=row>2</th><td>11/12/81</td><td>6</td><td>70</td><td> 50</td><td>1</td></tr>\n",
"\t<tr><th scope=row>9</th><td>2/03/84 </td><td>6</td><td>57</td><td>200</td><td>1</td></tr>\n",
"\t<tr><th scope=row>10</th><td>4/06/84 </td><td>6</td><td>63</td><td>200</td><td>1</td></tr>\n",
"\t<tr><th scope=row>11</th><td>8/30/84 </td><td>6</td><td>70</td><td>200</td><td>1</td></tr>\n",
"\t<tr><th scope=row>14</th><td>1/24/85 </td><td>6</td><td>53</td><td>200</td><td>2</td></tr>\n",
"\t<tr><th scope=row>21</th><td>10/30/85</td><td>6</td><td>75</td><td>200</td><td>2</td></tr>\n",
"\t<tr><th scope=row>23</th><td>1/12/86 </td><td>6</td><td>58</td><td>200</td><td>1</td></tr>\n",
"</tbody>\n",
"</table>\n"
],
"text/latex": [
"A data.frame: 7 × 5\n",
"\\begin{tabular}{r|lllll}\n",
" & Date & Count & Temperature & Pressure & Malfunction\\\\\n",
" & <fct> & <int> & <int> & <int> & <int>\\\\\n",
"\\hline\n",
"\t2 & 11/12/81 & 6 & 70 & 50 & 1\\\\\n",
"\t9 & 2/03/84 & 6 & 57 & 200 & 1\\\\\n",
"\t10 & 4/06/84 & 6 & 63 & 200 & 1\\\\\n",
"\t11 & 8/30/84 & 6 & 70 & 200 & 1\\\\\n",
"\t14 & 1/24/85 & 6 & 53 & 200 & 2\\\\\n",
"\t21 & 10/30/85 & 6 & 75 & 200 & 2\\\\\n",
"\t23 & 1/12/86 & 6 & 58 & 200 & 1\\\\\n",
"\\end{tabular}\n"
],
"text/markdown": [
"\n",
"A data.frame: 7 × 5\n",
"\n",
"| <!--/--> | Date &lt;fct&gt; | Count &lt;int&gt; | Temperature &lt;int&gt; | Pressure &lt;int&gt; | Malfunction &lt;int&gt; |\n",
"|---|---|---|---|---|---|\n",
"| 2 | 11/12/81 | 6 | 70 | 50 | 1 |\n",
"| 9 | 2/03/84 | 6 | 57 | 200 | 1 |\n",
"| 10 | 4/06/84 | 6 | 63 | 200 | 1 |\n",
"| 11 | 8/30/84 | 6 | 70 | 200 | 1 |\n",
"| 14 | 1/24/85 | 6 | 53 | 200 | 2 |\n",
"| 21 | 10/30/85 | 6 | 75 | 200 | 2 |\n",
"| 23 | 1/12/86 | 6 | 58 | 200 | 1 |\n",
"\n"
],
"text/plain": [
" Date Count Temperature Pressure Malfunction\n",
"2 11/12/81 6 70 50 1 \n",
"9 2/03/84 6 57 200 1 \n",
"10 4/06/84 6 63 200 1 \n",
"11 8/30/84 6 70 200 1 \n",
"14 1/24/85 6 53 200 2 \n",
"21 10/30/85 6 75 200 2 \n",
"23 1/12/86 6 58 200 1 "
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"data = data[data$Malfunction>0,]\n",
"data"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We have a high temperature variability but\n",
"the pressure is almost always 200, which should\n",
"simplify the analysis.\n",
"\n",
"How does the frequency of failure vary with temperature?"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [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19fX29vb39/f4+Pj5+fn6+vr7+/v8/Pz9/f3+/v7///9puzMQAAAA\nCXBIWXMAABJ0AAASdAHeZh94AAAgAElEQVR4nO3dC3SU5b3v8WdIhksgICi3cAlotbUtETxc\nWvBQo2WrWPTUgtgqEVqsgMZdVKBFQLywd2i1anW70b29HbcepFGPp8IRkSpFYQOixeIlokes\nQUESLZdwCXnXOnNLJoT0ncl+f7zv+8TvZy0zz5p5JvzX63xXkrkaB4BnJugBgNaAkAABQgIE\nCAkQICRAgJAAAUICBAgJECAkQICQAAFCAgQICRAgJECAkAABQgIECAkQICRAgJAAAUICBAgJ\nECAkQICQAAFCAgQICRAgJECAkAABQgIECAkQICRAgJAAAUICBAgJECAkQICQAAFCAgQICRAg\nJECAkAABQgIECAkQICRAgJAAAUICBAgJECAkQICQAAFCAgQICRAgJECAkAABQgIECAkQICRA\ngJAAAUICBAgJECAkQICQAAFCAgQICRAgJECAkAABQgIECAkQICRAgJAAAUICBAgJECAkQICQ\nAAFCAgQICRAgJECAkAABQgIECAkQICRAgJAAAUICBAgJECAkQICQAAFCAgQICRAgJECAkAAB\nQgIECAkQICRAgJAAAUICBAgJECAkQICQAAFCAgQICRDwIaQ3NgJWeaPlt/LjH9IGA1hmQ4tv\n5sc/pLXm4HH/NwChg2Zti69DSEAThAQIEBIgQEiAACEBAoQECBASIOB3SHXbVpaXr9qeYRch\nwTL+hlQ1s0fyUeD+C/e77SMkWMbXkCoHmlNL5peVzZ1YYAZVuWwkJFjG15CmRJemVrX3Rkpd\nNhISLONrSL0mp9cT+rlsJCRYxteQorel1wvaumwkJFjG15AKx6fX4wa4bCQkWMbXkEojiw8k\nV3vnmVkuGwkJlvE1pOrBJr+4ZMb0SaPzzKg9LhsJCZbx93Gkg3cU5cQfRooOX1Lrto+QYBnf\nnyJU896mTRWZMiEkWIbn2gEChAQIBBXS+8XFTc45snplg98SEuwSVEibTdPv8kH3rg3yzF7B\nvwH4JqiQarZscbn0fuN25zgQOuH8G4mQYJnAQvq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vn+kdj6vsGrY1/vMfc4zqLEr3aNQkptaXQlqBFSWCRCqjtp8I64MWZP\nLKSVsbN/ZR6Lfb3PLIuH9Gx84zmm8uhtj9d/i0M1q8zMZkJKbml8JagRUlgkQvq04X7wv8Ru\n/ltjZ883L8W+PmCeiIf0dnzjJPP60ds2Jq7/6FknxM8obTak+JbGV4IaIYVFIqQKU7Q8qTp2\n848/HDTfrHEaQvoovnGaeenYbc4cc+ZDf3ztwb8TUnxL4ytBjZDCIvUTqajhjGZCiv+Icn5s\n3jx2W02HfvFf2FY0DWlfOqTGV4IaIYVF8s6Gk9onflzsdJoN6ffxy4aancdu+9BcHD9jTjqk\ni0z80rfSITW+EtqClZMAAAEtSURBVNQIKSxS99qZX8a+7uw1ttmQLogt3418vZlt+yNnxL5u\n7mOucpwyU574Ti/Hvt7YKKRGV4IaIYVFMqTP+psrH769f/SFZkM6Z+z99w2I3wV3zDZnrLnq\niZu6Pp/b9z/2LjNDf/OfzmtmyEvr5ozKT4fU6EpQI6SwSD2zYcfV/XJP+MF6p9mQKq4raHv6\nw81tc3Ze1r3L2Wucmzv12nHohx26PuU4D5/eoefULwpGNmxpdCWoEZI9JpiPgx4Bfw8h2YOQ\nQoyQ7EFIIUZI9iCkECMkQICQAAFCAgQICRAgJECAkAABQgIECAkQICRAgJAAAUICBAgJECAk\nQICQAAFCAgQICRAgJECAkAABQgIECAkQICRAgJAAAUICBAgJECAkQICQAAFCAgT+P9FRuQB/\nRTZ+AAAAAElFTkSuQmCC",
"text/plain": [
"plot without title"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plot(data=data, Malfunction/Count ~ Temperature, ylim=c(0,1))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"At first glance, the dependence does not look very important, but let's try to\n",
"estimate the impact of temperature $t$ on the probability of O-ring malfunction."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Estimation of the temperature influence\n",
"\n",
"Suppose that each of the six O-rings is damaged with the same\n",
"probability and independently of the others and that this probability\n",
"depends only on the temperature. If $p(t)$ is this probability, the\n",
"number $D$ of malfunctioning O-rings during a flight at\n",
"temperature $t$ follows a binomial law with parameters $n=6$ and\n",
"$p=p(t)$. To link $p(t)$ to $t$, we will therefore perform a\n",
"logistic regression."
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"\n",
"Call:\n",
"glm(formula = Malfunction/Count ~ Temperature, family = binomial(link = \"logit\"), \n",
" data = data, weights = Count)\n",
"\n",
"Deviance Residuals: \n",
" 2 9 10 11 14 21 23 \n",
"-0.3015 -0.2836 -0.2919 -0.3015 0.6891 0.6560 -0.2850 \n",
"\n",
"Coefficients:\n",
" Estimate Std. Error z value Pr(>|z|)\n",
"(Intercept) -1.389528 3.195752 -0.435 0.664\n",
"Temperature 0.001416 0.049773 0.028 0.977\n",
"\n",
"(Dispersion parameter for binomial family taken to be 1)\n",
"\n",
" Null deviance: 1.3347 on 6 degrees of freedom\n",
"Residual deviance: 1.3339 on 5 degrees of freedom\n",
"AIC: 18.894\n",
"\n",
"Number of Fisher Scoring iterations: 4\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"logistic_reg = glm(data=data, Malfunction/Count ~ Temperature, weights=Count, \n",
" family=binomial(link='logit'))\n",
"summary(logistic_reg)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The most likely estimator of the temperature parameter is 0.0014\n",
"and the standard error of this estimator is 0.122, in other words we\n",
"cannot distinguish any particular impact and we must take our\n",
"estimates with caution."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Estimation of the probability of O-ring malfunction\n",
"\n",
"The expected temperature on the take-off day is 31°F. Let's try to\n",
"estimate the probability of O-ring malfunction at\n",
"this temperature from the model we just built:"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA0gAAANICAMAAADKOT/pAAAC/VBMVE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hM57L\nzXWp0009ztpvSN9OHa7O+VLqdGeHC08pqktyvQcnQsp6C8wJP/9zsLG3ueS+n/bOf2q/IQ07\n6647+5iH7PBLOuddl+yCD0qElPV2ndu602+C4MPLe+V1/M7LwX5DqvxBz5bH3BcOf8qknzHB\nKUJqBkaZ9Ukv4aBHSM0AISWPkJoBQkoeITUDhJQ8QgIECAkQICRAgJAAAUICBAgJECAkQICQ\nAAFCAgQICRAgJECAkAABQgIECAkQICRAgJAAAUICBAgJECAkQICQAAFCAgQICRAgJECAkAAB\nQgIECAkQICRA4H8AHOKqM1UAAAADSURBVHhzjEM0knQAAAAASUVORK5CYII=",
"text/plain": [
"plot without title"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"tempv = seq(from=30, to=90, by = .5)\n",
"rmv <- predict(logistic_reg,list(Temperature=tempv),type=\"response\")\n",
"plot(tempv,rmv,type=\"l\",ylim=c(0,1))\n",
"points(data=data, Malfunction/Count ~ Temperature)"
]
},
{
"cell_type": "markdown",
"metadata": {
"hideCode": false,
"hidePrompt": false,
"scrolled": true
},
"source": [
"As expected from the initial data, the\n",
"temperature has no significant impact on the probability of failure of the\n",
"O-rings. It will be about 0.2, as in the tests\n",
"where we had a failure of at least one joint. Let's get back\n",
"to the initial dataset to estimate the probability of failure:"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"0.0652173913043478"
],
"text/latex": [
"0.0652173913043478"
],
"text/markdown": [
"0.0652173913043478"
],
"text/plain": [
"[1] 0.06521739"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"data_full = read.csv(\"shuttle.csv\",header=T)\n",
"sum(data_full$Malfunction)/sum(data_full$Count)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This probability is thus about $p=0.065$. Knowing that there is\n",
"a primary and a secondary O-ring on each of the three parts of the\n",
"launcher, the probability of failure of both joints of a launcher\n",
"is $p^2 \\approx 0.00425$. The probability of failure of any one of the\n",
"launchers is $1-(1-p^2)^3 \\approx 1.2\\%$. That would really be\n",
"bad luck.... Everything is under control, so the takeoff can happen\n",
"tomorrow as planned.\n",
"\n",
"But the next day, the Challenger shuttle exploded and took away\n",
"with her the seven crew members. The public was shocked and in\n",
"the subsequent investigation, the reliability of the\n",
"O-rings was questioned. Beyond the internal communication problems\n",
"of NASA, which have a lot to do with this fiasco, the previous analysis\n",
"includes (at least) a small problem.... Can you find it?\n",
"You are free to modify this analysis and to look at this dataset\n",
"from all angles in order to to explain what's wrong."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"celltoolbar": "Hide code",
"kernelspec": {
"display_name": "R",
"language": "R",
"name": "ir"
},
"language_info": {
"codemirror_mode": "r",
"file_extension": ".r",
"mimetype": "text/x-r-source",
"name": "R",
"pygments_lexer": "r",
"version": "3.6.1"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
#+TITLE: Analysis of the risk of failure of the O-rings on the Challenger shuttle
#+AUTHOR: Arnaud Legrand
#+LANGUAGE: en
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="http://www.pirilampo.org/styles/readtheorg/css/htmlize.css"/>
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="http://www.pirilampo.org/styles/readtheorg/css/readtheorg.css"/>
#+HTML_HEAD: <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
#+HTML_HEAD: <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
#+HTML_HEAD: <script type="text/javascript" src="http://www.pirilampo.org/styles/lib/js/jquery.stickytableheaders.js"></script>
#+HTML_HEAD: <script type="text/javascript" src="http://www.pirilampo.org/styles/readtheorg/js/readtheorg.js"></script>
#+LATEX_HEADER: \usepackage[utf8]{inputenc}
#+LATEX_HEADER: \usepackage[T1]{fontenc}
#+LATEX_HEADER: \usepackage[a4paper,margin=.8in]{geometry}
#+LATEX_HEADER: \usepackage[french]{babel}
# #+PROPERTY: header-args :session :exports both
On January 27, 1986, the day before the takeoff of the shuttle /Challenger/, had
a three-hour teleconference was held between
Morton Thiokol (the manufacturer of one of the engines) and NASA. The
discussion focused on the consequences of the
temperature at take-off of 31°F (just below
0°C) for the success of the flight and in particular on the performance of the
O-rings used in the engines. Indeed, no test
had been performed at this temperature.
The following study takes up some of the analyses carried out that
night with the objective of assessing the potential influence of
the temperature and pressure to which the O-rings are subjected
on their probability of malfunction. Our starting point is
the results of the experiments carried out by NASA engineers
during the six years preceding the launch of the shuttle
Challenger.
* Loading the data
We start by loading this data:
#+begin_src R :results output :session *R* :exports both
data = read.csv("shuttle.csv",header=T)
data
#+end_src
#+RESULTS:
#+begin_example
Date Count Temperature Pressure Malfunction
1 4/12/81 6 66 50 0
2 11/12/81 6 70 50 1
3 3/22/82 6 69 50 0
4 11/11/82 6 68 50 0
5 4/04/83 6 67 50 0
6 6/18/82 6 72 50 0
7 8/30/83 6 73 100 0
8 11/28/83 6 70 100 0
9 2/03/84 6 57 200 1
10 4/06/84 6 63 200 1
11 8/30/84 6 70 200 1
12 10/05/84 6 78 200 0
13 11/08/84 6 67 200 0
14 1/24/85 6 53 200 2
15 4/12/85 6 67 200 0
16 4/29/85 6 75 200 0
17 6/17/85 6 70 200 0
18 7/29/85 6 81 200 0
19 8/27/85 6 76 200 0
20 10/03/85 6 79 200 0
21 10/30/85 6 75 200 2
22 11/26/85 6 76 200 0
23 1/12/86 6 58 200 1
#+end_example
The data set shows us the date of each test, the number of O-rings
(there are 6 on the main launcher), the
temperature (in Fahrenheit) and pressure (in psi), and finally the
number of identified malfunctions.
* Graphical inspection
Flights without incidents do not provide any information
on the influence of temperature or pressure on malfunction.
We thus focus on the experiments in which at least one O-ring was defective.
#+begin_src R :results output :session *R* :exports both
data = data[data$Malfunction>0,]
data
#+end_src
#+RESULTS:
: Date Count Temperature Pressure Malfunction
: 2 11/12/81 6 70 50 1
: 9 2/03/84 6 57 200 1
: 10 4/06/84 6 63 200 1
: 11 8/30/84 6 70 200 1
: 14 1/24/85 6 53 200 2
: 21 10/30/85 6 75 200 2
: 23 1/12/86 6 58 200 1
We have a high temperature variability but
the pressure is almost always 200, which should
simplify the analysis.
How does the frequency of failure vary with temperature?
#+begin_src R :results output graphics :file "freq_temp.png" :exports both :width 600 :height 400 :session *R*
plot(data=data, Malfunction/Count ~ Temperature, ylim=c(0,1))
#+end_src
#+RESULTS:
[[file:freq_temp.png]]
At first glance, the dependence does not look very important, but let's try to
estimate the impact of temperature $t$ on the probability of O-ring malfunction.
* Estimation of the temperature influence
Suppose that each of the six O-rings is damaged with the same
probability and independently of the others and that this probability
depends only on the temperature. If $p(t)$ is this probability, the
number $D$ of malfunctioning O-rings during a flight at
temperature $t$ follows a binomial law with parameters $n=6$ and
$p=p(t)$. To link $p(t)$ to $t$, we will therefore perform a
logistic regression.
#+begin_src R :results output :session *R* :exports both
logistic_reg = glm(data=data, Malfunction/Count ~ Temperature, weights=Count,
family=binomial(link='logit'))
summary(logistic_reg)
#+end_src
#+RESULTS:
#+begin_example
Call:
glm(formula = Malfunction/Count ~ Temperature, family = binomial(link = "logit"),
data = data, weights = Count)
Deviance Residuals:
2 9 10 11 14 21 23
-0.3015 -0.2836 -0.2919 -0.3015 0.6891 0.6560 -0.2850
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -1.389528 3.195752 -0.435 0.664
Temperature 0.001416 0.049773 0.028 0.977
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 1.3347 on 6 degrees of freedom
Residual deviance: 1.3339 on 5 degrees of freedom
AIC: 18.894
Number of Fisher Scoring iterations: 4
#+end_example
The most likely estimator of the temperature parameter is 0.001416
and the standard error of this estimator is 0.049, in other words we
cannot distinguish any particular impact and we must take our
estimates with caution.
* Estimation of the probability of O-ring malfunction
The expected temperature on the take-off day is 31°F. Let's try to
estimate the probability of O-ring malfunction at
this temperature from the model we just built:
#+begin_src R :results output graphics :file "proba_estimate.png" :exports both :width 600 :height 400 :session *R*
# shuttle=shuttle[shuttle$r!=0,]
tempv = seq(from=30, to=90, by = .5)
rmv <- predict(logistic_reg,list(Temperature=tempv),type="response")
plot(tempv,rmv,type="l",ylim=c(0,1))
points(data=data, Malfunction/Count ~ Temperature)
#+end_src
#+RESULTS:
[[file:proba_estimate.png]]
As expected from the initial data, the
temperature has no significant impact on the probability of failure of the
O-rings. It will be about 0.2, as in the tests
where we had a failure of at least one joint. Let's get back to the initial dataset to estimate the probability of failure:
#+begin_src R :results output :session *R* :exports both
data_full = read.csv("shuttle.csv",header=T)
sum(data_full$Malfunction)/sum(data_full$Count)
#+end_src
#+RESULTS:
: [1] 0.06521739
This probability is thus about $p=0.065$. Knowing that there is
a primary and a secondary O-ring on each of the three parts of the
launcher, the probability of failure of both joints of a launcher
is $p^2 \approx 0.00425$. The probability of failure of any one of the
launchers is $1-(1-p^2)^3 \approx 1.2%$. That would really be
bad luck.... Everything is under control, so the takeoff can happen
tomorrow as planned.
But the next day, the Challenger shuttle exploded and took away
with her the seven crew members. The public was shocked and in
the subsequent investigation, the reliability of the
O-rings was questioned. Beyond the internal communication problems
of NASA, which have a lot to do with this fiasco, the previous analysis
includes (at least) a small problem.... Can you find it?
You are free to modify this analysis and to look at this dataset
from all angles in order to to explain what's wrong.
---
title: "Analysis of the risk of failure of the O-rings on the Challenger shuttle"
author: "Arnaud Legrand"
date: "28 juin 2018"
output: html_document
---
On January 27, 1986, the day before the takeoff of the shuttle _Challenger_, had
a three-hour teleconference was held between
Morton Thiokol (the manufacturer of one of the engines) and NASA. The
discussion focused on the consequences of the
temperature at take-off of 31°F (just below
0°C) for the success of the flight and in particular on the performance of the
O-rings used in the engines. Indeed, no test
had been performed at this temperature.
The following study takes up some of the analyses carried out that
night with the objective of assessing the potential influence of
the temperature and pressure to which the O-rings are subjected
on their probability of malfunction. Our starting point is
the results of the experiments carried out by NASA engineers
during the six years preceding the launch of the shuttle
Challenger.
# Loading the data
We start by loading this data:
```{r}
data = read.csv("shuttle.csv",header=T)
data
```
The data set shows us the date of each test, the number of O-rings
(there are 6 on the main launcher), the
temperature (in Fahrenheit) and pressure (in psi), and finally the
number of identified malfunctions.
# Graphical inspection
Flights without incidents do not provide any information
on the influence of temperature or pressure on malfunction.
We thus focus on the experiments in which at least one O-ring was defective.
```{r}
data = data[data$Malfunction>0,]
data
```
We have a high temperature variability but
the pressure is almost always 200, which should
simplify the analysis.
How does the frequency of failure vary with temperature?
```{r}
plot(data=data, Malfunction/Count ~ Temperature, ylim=c(0,1))
```
At first glance, the dependence does not look very important, but let's try to
estimate the impact of temperature $t$ on the probability of O-ring malfunction.
# Estimation of the temperature influence
Suppose that each of the six O-rings is damaged with the same
probability and independently of the others and that this probability
depends only on the temperature. If $p(t)$ is this probability, the
number $D$ of malfunctioning O-rings during a flight at
temperature $t$ follows a binomial law with parameters $n=6$ and
$p=p(t)$. To link $p(t)$ to $t$, we will therefore perform a
logistic regression.
```{r}
logistic_reg = glm(data=data, Malfunction/Count ~ Temperature, weights=Count,
family=binomial(link='logit'))
summary(logistic_reg)
```
The most likely estimator of the temperature parameter is 0.001416
and the standard error of this estimator is 0.049, in other words we
cannot distinguish any particular impact and we must take our
estimates with caution.
# Estimation of the probability of O-ring malfunction
The expected temperature on the take-off day is 31°F. Let's try to
estimate the probability of O-ring malfunction at
this temperature from the model we just built:
```{r}
# shuttle=shuttle[shuttle$r!=0,]
tempv = seq(from=30, to=90, by = .5)
rmv <- predict(logistic_reg,list(Temperature=tempv),type="response")
plot(tempv,rmv,type="l",ylim=c(0,1))
points(data=data, Malfunction/Count ~ Temperature)
```
As expected from the initial data, the
temperature has no significant impact on the probability of failure of the
O-rings. It will be about 0.2, as in the tests
where we had a failure of at least one joint. Let's get back to the initial dataset to estimate the probability of failure:
```{r}
data_full = read.csv("shuttle.csv",header=T)
sum(data_full$Malfunction)/sum(data_full$Count)
```
This probability is thus about $p=0.065$. Knowing that there is
a primary and a secondary O-ring on each of the three parts of the
launcher, the probability of failure of both joints of a launcher
is $p^2 \approx 0.00425$. The probability of failure of any one of the
launchers is $1-(1-p^2)^3 \approx 1.2%$. That would really be
bad luck.... Everything is under control, so the takeoff can happen
tomorrow as planned.
But the next day, the Challenger shuttle exploded and took away
with her the seven crew members. The public was shocked and in
the subsequent investigation, the reliability of the
O-rings was questioned. Beyond the internal communication problems
of NASA, which have a lot to do with this fiasco, the previous analysis
includes (at least) a small problem.... Can you find it?
You are free to modify this analysis and to look at this dataset
from all angles in order to to explain what's wrong.
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Analysis of the risk of failure of the O-rings on the Challenger shuttle"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"On January 27, 1986, the day before the takeoff of the shuttle _Challenger_, had\n",
"a three-hour teleconference was held between \n",
"Morton Thiokol (the manufacturer of one of the engines) and NASA. The\n",
"discussion focused on the consequences of the\n",
"temperature at take-off of 31°F (just below\n",
"0°C) for the success of the flight and in particular on the performance of the\n",
"O-rings used in the engines. Indeed, no test\n",
"had been performed at this temperature.\n",
"\n",
"The following study takes up some of the analyses carried out that\n",
"night with the objective of assessing the potential influence of\n",
"the temperature and pressure to which the O-rings are subjected\n",
"on their probability of malfunction. Our starting point is \n",
"the results of the experiments carried out by NASA engineers\n",
"during the six years preceding the launch of the shuttle\n",
"Challenger."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Loading the data\n",
"We start by loading this data:"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Date</th>\n",
" <th>Count</th>\n",
" <th>Temperature</th>\n",
" <th>Pressure</th>\n",
" <th>Malfunction</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>4/12/81</td>\n",
" <td>6</td>\n",
" <td>66</td>\n",
" <td>50</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>11/12/81</td>\n",
" <td>6</td>\n",
" <td>70</td>\n",
" <td>50</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>3/22/82</td>\n",
" <td>6</td>\n",
" <td>69</td>\n",
" <td>50</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>11/11/82</td>\n",
" <td>6</td>\n",
" <td>68</td>\n",
" <td>50</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>4/04/83</td>\n",
" <td>6</td>\n",
" <td>67</td>\n",
" <td>50</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>6/18/82</td>\n",
" <td>6</td>\n",
" <td>72</td>\n",
" <td>50</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>8/30/83</td>\n",
" <td>6</td>\n",
" <td>73</td>\n",
" <td>100</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>11/28/83</td>\n",
" <td>6</td>\n",
" <td>70</td>\n",
" <td>100</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>2/03/84</td>\n",
" <td>6</td>\n",
" <td>57</td>\n",
" <td>200</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>4/06/84</td>\n",
" <td>6</td>\n",
" <td>63</td>\n",
" <td>200</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>8/30/84</td>\n",
" <td>6</td>\n",
" <td>70</td>\n",
" <td>200</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>10/05/84</td>\n",
" <td>6</td>\n",
" <td>78</td>\n",
" <td>200</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>11/08/84</td>\n",
" <td>6</td>\n",
" <td>67</td>\n",
" <td>200</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>13</th>\n",
" <td>1/24/85</td>\n",
" <td>6</td>\n",
" <td>53</td>\n",
" <td>200</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>14</th>\n",
" <td>4/12/85</td>\n",
" <td>6</td>\n",
" <td>67</td>\n",
" <td>200</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15</th>\n",
" <td>4/29/85</td>\n",
" <td>6</td>\n",
" <td>75</td>\n",
" <td>200</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16</th>\n",
" <td>6/17/85</td>\n",
" <td>6</td>\n",
" <td>70</td>\n",
" <td>200</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>17</th>\n",
" <td>7/29/85</td>\n",
" <td>6</td>\n",
" <td>81</td>\n",
" <td>200</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18</th>\n",
" <td>8/27/85</td>\n",
" <td>6</td>\n",
" <td>76</td>\n",
" <td>200</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>19</th>\n",
" <td>10/03/85</td>\n",
" <td>6</td>\n",
" <td>79</td>\n",
" <td>200</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>20</th>\n",
" <td>10/30/85</td>\n",
" <td>6</td>\n",
" <td>75</td>\n",
" <td>200</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>21</th>\n",
" <td>11/26/85</td>\n",
" <td>6</td>\n",
" <td>76</td>\n",
" <td>200</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>22</th>\n",
" <td>1/12/86</td>\n",
" <td>6</td>\n",
" <td>58</td>\n",
" <td>200</td>\n",
" <td>1</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Date Count Temperature Pressure Malfunction\n",
"0 4/12/81 6 66 50 0\n",
"1 11/12/81 6 70 50 1\n",
"2 3/22/82 6 69 50 0\n",
"3 11/11/82 6 68 50 0\n",
"4 4/04/83 6 67 50 0\n",
"5 6/18/82 6 72 50 0\n",
"6 8/30/83 6 73 100 0\n",
"7 11/28/83 6 70 100 0\n",
"8 2/03/84 6 57 200 1\n",
"9 4/06/84 6 63 200 1\n",
"10 8/30/84 6 70 200 1\n",
"11 10/05/84 6 78 200 0\n",
"12 11/08/84 6 67 200 0\n",
"13 1/24/85 6 53 200 2\n",
"14 4/12/85 6 67 200 0\n",
"15 4/29/85 6 75 200 0\n",
"16 6/17/85 6 70 200 0\n",
"17 7/29/85 6 81 200 0\n",
"18 8/27/85 6 76 200 0\n",
"19 10/03/85 6 79 200 0\n",
"20 10/30/85 6 75 200 2\n",
"21 11/26/85 6 76 200 0\n",
"22 1/12/86 6 58 200 1"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import numpy as np\n",
"import pandas as pd\n",
"data = pd.read_csv(\"shuttle.csv\")\n",
"data"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The data set shows us the date of each test, the number of O-rings (there are 6 on the main launcher), the temperature (in Fahrenheit) and pressure (in psi), and finally the number of identified malfunctions."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Graphical inspection\n",
"Flights without incidents do not provide any information\n",
"on the influence of temperature or pressure on malfunction.\n",
"We thus focus on the experiments in which at least one O-ring\n",
"was defective."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Date</th>\n",
" <th>Count</th>\n",
" <th>Temperature</th>\n",
" <th>Pressure</th>\n",
" <th>Malfunction</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>11/12/81</td>\n",
" <td>6</td>\n",
" <td>70</td>\n",
" <td>50</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>2/03/84</td>\n",
" <td>6</td>\n",
" <td>57</td>\n",
" <td>200</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>4/06/84</td>\n",
" <td>6</td>\n",
" <td>63</td>\n",
" <td>200</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>8/30/84</td>\n",
" <td>6</td>\n",
" <td>70</td>\n",
" <td>200</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>13</th>\n",
" <td>1/24/85</td>\n",
" <td>6</td>\n",
" <td>53</td>\n",
" <td>200</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>20</th>\n",
" <td>10/30/85</td>\n",
" <td>6</td>\n",
" <td>75</td>\n",
" <td>200</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>22</th>\n",
" <td>1/12/86</td>\n",
" <td>6</td>\n",
" <td>58</td>\n",
" <td>200</td>\n",
" <td>1</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Date Count Temperature Pressure Malfunction\n",
"1 11/12/81 6 70 50 1\n",
"8 2/03/84 6 57 200 1\n",
"9 4/06/84 6 63 200 1\n",
"10 8/30/84 6 70 200 1\n",
"13 1/24/85 6 53 200 2\n",
"20 10/30/85 6 75 200 2\n",
"22 1/12/86 6 58 200 1"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data = data[data.Malfunction>0]\n",
"data"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We have a high temperature variability but\n",
"the pressure is almost always 200, which should\n",
"simplify the analysis.\n",
"\n",
"How does the frequency of failure vary with temperature?"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEKCAYAAAD9xUlFAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAFaNJREFUeJzt3X2QZXV95/H3p2cGGASFwGZiMSAQWFdKCWALGtxkiMRCqxzWwgfYSjRGnWwJlTImRuK6hLCmaiUxJlaIOroaYUuRh1Vnd3ERNK3REmHUCY/BzCJCgwHFUWkY5oH+7h/3zvFOd0/37aHPvUz3+1XVNfec+zvnfvvL4X76PNxzU1VIkgQwMuwCJElPH4aCJKlhKEiSGoaCJKlhKEiSGoaCJKnRWigk+XiSh5Pcvofnk+SDSTYnuTXJKW3VIknqT5t7Cn8PnDXL868Aju/+rAM+1GItkqQ+tBYKVfVV4MezDDkbuLw6bgIOSfLstuqRJM1t+RBf+wjg/p7p8e68H0wdmGQdnb0JVq5c+cIjjzxyIAU+VZOTk4yMeNqmlz2Zzp5MZ09m9lT68t3vfvdHVfVv5ho3zFDIDPNmvOdGVa0H1gOMjo7Wxo0b26xrwYyNjbFmzZphl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o1JAFbSuX0AwNaquqH7+Dbgp1W1M8ltwNE967i+qrYAJPkc8FI6///sab3b+fmtTwBeluSdwAHA4cC3gC/M8/f4fFU90X38cuB5SXpD6Hg6t4OQ9pqhoKUgwMer6r/sNjNZTufNe5dJYFvP497/P6aefKs51ru1uifsuvew+Vs6d0N9IMl76YTDTHby8z34qWMem/I7va2qvoS0gDx8pKXgRuB1SQ6HzlVKe3Go5eXpfLfygXS+Eezr81jvSjoh86Pu3XTP6XnuUeDgnul7gRd2H/eOm+p64G3dANr1nb4r5/k7SdO4p6BFr6puS/JnwI1JRoAdwH8CHpzHar4GfIrOF5xcsetqoX7WW1WPpPO9zLcD3we+2fP0J4CPJdlK57zFxcBHk/wrcPMs9XyEzt1DN3UPXT1MJ6ykp8RLUqU5dK/seX5VvX3YtUht8/CRJKnhnoIkqeGegiSpYShIkhqGgiSpYShIkhqGgiSp8f8B+Q9eu+sB8EwAAAAASUVORK5CYII=\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"%matplotlib inline\n",
"pd.set_option('mode.chained_assignment',None) # this removes a useless warning from pandas\n",
"import matplotlib.pyplot as plt\n",
"\n",
"data[\"Frequency\"]=data.Malfunction/data.Count\n",
"data.plot(x=\"Temperature\",y=\"Frequency\",kind=\"scatter\",ylim=[0,1])\n",
"plt.grid(True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"At first glance, the dependence does not look very important, but let's try to\n",
"estimate the impact of temperature $t$ on the probability of O-ring malfunction."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Estimation of the temperature influence\n",
"\n",
"Suppose that each of the six O-rings is damaged with the same\n",
"probability and independently of the others and that this probability\n",
"depends only on the temperature. If $p(t)$ is this probability, the\n",
"number $D$ of malfunctioning O-rings during a flight at\n",
"temperature $t$ follows a binomial law with parameters $n=6$ and\n",
"$p=p(t)$. To link $p(t)$ to $t$, we will therefore perform a\n",
"logistic regression."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<table class=\"simpletable\">\n",
"<caption>Generalized Linear Model Regression Results</caption>\n",
"<tr>\n",
" <th>Dep. Variable:</th> <td>Frequency</td> <th> No. Observations: </th> <td> 7</td> \n",
"</tr>\n",
"<tr>\n",
" <th>Model:</th> <td>GLM</td> <th> Df Residuals: </th> <td> 5</td> \n",
"</tr>\n",
"<tr>\n",
" <th>Model Family:</th> <td>Binomial</td> <th> Df Model: </th> <td> 1</td> \n",
"</tr>\n",
"<tr>\n",
" <th>Link Function:</th> <td>logit</td> <th> Scale: </th> <td> 1.0000</td> \n",
"</tr>\n",
"<tr>\n",
" <th>Method:</th> <td>IRLS</td> <th> Log-Likelihood: </th> <td> -2.5250</td> \n",
"</tr>\n",
"<tr>\n",
" <th>Date:</th> <td>Sat, 13 Apr 2019</td> <th> Deviance: </th> <td> 0.22231</td> \n",
"</tr>\n",
"<tr>\n",
" <th>Time:</th> <td>19:12:05</td> <th> Pearson chi2: </th> <td> 0.236</td> \n",
"</tr>\n",
"<tr>\n",
" <th>No. Iterations:</th> <td>4</td> <th> Covariance Type: </th> <td>nonrobust</td>\n",
"</tr>\n",
"</table>\n",
"<table class=\"simpletable\">\n",
"<tr>\n",
" <td></td> <th>coef</th> <th>std err</th> <th>z</th> <th>P>|z|</th> <th>[0.025</th> <th>0.975]</th> \n",
"</tr>\n",
"<tr>\n",
" <th>Intercept</th> <td> -1.3895</td> <td> 7.828</td> <td> -0.178</td> <td> 0.859</td> <td> -16.732</td> <td> 13.953</td>\n",
"</tr>\n",
"<tr>\n",
" <th>Temperature</th> <td> 0.0014</td> <td> 0.122</td> <td> 0.012</td> <td> 0.991</td> <td> -0.238</td> <td> 0.240</td>\n",
"</tr>\n",
"</table>"
],
"text/plain": [
"<class 'statsmodels.iolib.summary.Summary'>\n",
"\"\"\"\n",
" Generalized Linear Model Regression Results \n",
"==============================================================================\n",
"Dep. Variable: Frequency No. Observations: 7\n",
"Model: GLM Df Residuals: 5\n",
"Model Family: Binomial Df Model: 1\n",
"Link Function: logit Scale: 1.0000\n",
"Method: IRLS Log-Likelihood: -2.5250\n",
"Date: Sat, 13 Apr 2019 Deviance: 0.22231\n",
"Time: 19:12:05 Pearson chi2: 0.236\n",
"No. Iterations: 4 Covariance Type: nonrobust\n",
"===============================================================================\n",
" coef std err z P>|z| [0.025 0.975]\n",
"-------------------------------------------------------------------------------\n",
"Intercept -1.3895 7.828 -0.178 0.859 -16.732 13.953\n",
"Temperature 0.0014 0.122 0.012 0.991 -0.238 0.240\n",
"===============================================================================\n",
"\"\"\""
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import statsmodels.api as sm\n",
"\n",
"data[\"Success\"]=data.Count-data.Malfunction\n",
"data[\"Intercept\"]=1\n",
"\n",
"logmodel=sm.GLM(data['Frequency'], data[['Intercept','Temperature']], family=sm.families.Binomial(sm.families.links.logit)).fit()\n",
"\n",
"logmodel.summary()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The most likely estimator of the temperature parameter is 0.0014\n",
"and the standard error of this estimator is 0.122, in other words we\n",
"cannot distinguish any particular impact and we must take our\n",
"estimates with caution."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Estimation of the probability of O-ring malfunction\n",
"\n",
"The expected temperature on the take-off day is 31°F. Let's try to\n",
"estimate the probability of O-ring malfunction at\n",
"this temperature from the model we just built:"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAEKCAYAAAAcgp5RAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAGyFJREFUeJzt3X2UVPWd5/H3p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iCFauXMmWLVt4/vnniQjmzp3LL37xC0aPHs2DDz7ImjVraG1tZfr06Zxyyin7Xd8999zD2LFjWbVqFR9++CGzZ8/ufDFZs2YNGzZs4Oijj2b27Nk8/fTTzJw5kyuuuIKHHnqIGTNm8N5771FXV8f8+fO57777uP3223nllVf48MMPOemkkyrwrJXmoDezqlXq1A3AeeedxxFHHAHAypUrWblyJdOmTQOgubmZLVu2sGvXLj7/+c8zatQoAObOndvj+lauXMm6det4+OGHAXj33XfZsmULI0aMYObMmUycOBGAqVOnsm3bNsaOHctRRx3FjBkzADjssMMAuOyyy/jOd77DokWLuPfee7nmmmsO7InogYPezA5YT0feA2306NGdtyOCG264ga985Std2tx+++3dXsI4bNgw2tvbAbpcyx4RfP/732fOnDld2jc2NnLIIYd0TtfW1tLa2kpElFzHqFGjOO+883jsscdYsmRJ52mi/uJz9GaWtDlz5nDvvffS3NwMwPbt29m5cydnnXUWjz76KC0tLezatYuf/vSnnY+ZNGkSL7zwAkDn0XvHsu6880727NkDwCuvvML777/f7bqPO+44duzYwapVq4DsjeLW1lYA5s+fz3XXXceMGTM6//voLz6iN7OknX/++WzatInTTz8dgEMPPZQf/vCHTJ8+nSuuuIKpU6fyiU98gjPPPLPzMddffz2XX345999/P+ecc07n/Pnz57Nt2zamT59ORDB+/HiWLl3a7bpHjBjBQw89xFe/+lVaWlqoq6vjiSee4NBDD+WUU07hsMMO44tfHIBxICNiUH4+9alPRcqeeuqpwS6hX6Xcv5T7FlG5/m3cuLEiy6m09957r0+Pu/HGG2PRokUVrqZ727dvjylTpkRbW1u3bUo9x8Dq6GXe+tSNmdkA+8EPfsCsWbO49dZbB+RrD33qxswMuOmmmwZsXVdffTVXX331gK3PR/Rm1mcRJb8e2iqgks+tg97M+mTkyJG89dZbDvt+EPl49CNHjqzI8nzqxsz6ZOLEiTQ1NfHGG28Mdild7N69u2IBOZg6vmGqEhz0ZtYnw4cPr8i3H1VaY2Nj56dgLeNTN2ZmiXPQm5klzkFvZpY4B72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DwFrgisjGfu/p1NI04KKI+CNgAdmgeDOBGWSDxh3bl+fHrDs+R2/V5FyyMFydDW1CHdlH+wFaIuLx/PZ64N2IaJW0HphUsIwVEfE2gKSlwH8g2w+6W+5H7B0CAuAzkhYCI4EjyYbF/cde9uOxiNid3z4f+LSkwheWKWQfbTerCAe9VRMB90bEX3SZmY1UWHgU3U72rWYdtwv/zovflIoeltsS+RtZ+Zgx/xeYHhHbJd1CFviltLL3P+biNu8X9elPI+JJzPqJT91YNXkCuFzSkZBdndOH0xznK/uO2FFkY5k/3Yvl1pG9cLyZj+j5nwru2wWMKZjeRvbVfRS1K7YC+NOOYXWVfcdrXS/7ZLZfPqK3qhER6/PRCp+QVEM2ot9/oXfjjf8r8GPgD4D7O66SKWe5EfGWpH8gG6b5V8BzBXf/PXC3pBay9wFuAv5O0m+A5/dTz11koxCuzU8b7SR7ATKrGF9eaQeN/IqWEyLia4Ndi9lA8qkbM7PE+YjezCxxPqI3M0ucg97MLHEOejOzxDnozcwS56A3M0vc/wcowwoTqhaBUgAAAABJRU5ErkJggg==\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"%matplotlib inline\n",
"data_pred = pd.DataFrame({'Temperature': np.linspace(start=30, stop=90, num=121), 'Intercept': 1})\n",
"data_pred['Frequency'] = logmodel.predict(data_pred[['Intercept','Temperature']])\n",
"data_pred.plot(x=\"Temperature\",y=\"Frequency\",kind=\"line\",ylim=[0,1])\n",
"plt.scatter(x=data[\"Temperature\"],y=data[\"Frequency\"])\n",
"plt.grid(True)"
]
},
{
"cell_type": "markdown",
"metadata": {
"hideCode": false,
"hidePrompt": false,
"scrolled": true
},
"source": [
"As expected from the initial data, the\n",
"temperature has no significant impact on the probability of failure of the\n",
"O-rings. It will be about 0.2, as in the tests\n",
"where we had a failure of at least one joint. Let's get back\n",
"to the initial dataset to estimate the probability of failure:"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.06521739130434782\n"
]
}
],
"source": [
"data = pd.read_csv(\"shuttle.csv\")\n",
"print(np.sum(data.Malfunction)/np.sum(data.Count))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This probability is thus about $p=0.065$. Knowing that there is\n",
"a primary and a secondary O-ring on each of the three parts of the\n",
"launcher, the probability of failure of both joints of a launcher\n",
"is $p^2 \\approx 0.00425$. The probability of failure of any one of the\n",
"launchers is $1-(1-p^2)^3 \\approx 1.2%$. That would really be\n",
"bad luck.... Everything is under control, so the takeoff can happen\n",
"tomorrow as planned.\n",
"\n",
"But the next day, the Challenger shuttle exploded and took away\n",
"with her the seven crew members. The public was shocked and in\n",
"the subsequent investigation, the reliability of the\n",
"O-rings was questioned. Beyond the internal communication problems\n",
"of NASA, which have a lot to do with this fiasco, the previous analysis\n",
"includes (at least) a small problem.... Can you find it?\n",
"You are free to modify this analysis and to look at this dataset\n",
"from all angles in order to to explain what's wrong."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"celltoolbar": "Hide code",
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
#+TITLE: Analysis of the risk of failure of the O-rings on the Challenger shuttle
#+AUTHOR: Arnaud Legrand
#+LANGUAGE: en
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="http://www.pirilampo.org/styles/readtheorg/css/htmlize.css"/>
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="http://www.pirilampo.org/styles/readtheorg/css/readtheorg.css"/>
#+HTML_HEAD: <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
#+HTML_HEAD: <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
#+HTML_HEAD: <script type="text/javascript" src="http://www.pirilampo.org/styles/lib/js/jquery.stickytableheaders.js"></script>
#+HTML_HEAD: <script type="text/javascript" src="http://www.pirilampo.org/styles/readtheorg/js/readtheorg.js"></script>
#+LATEX_HEADER: \usepackage{a4}
#+LATEX_HEADER: \usepackage[french]{babel}
# #+PROPERTY: header-args :session :exports both
On January 27, 1986, the day before the takeoff of the shuttle /Challenger/, had
a three-hour teleconference was held between
Morton Thiokol (the manufacturer of one of the engines) and NASA. The
discussion focused on the consequences of the
temperature at take-off of 31°F (just below
0°C) for the success of the flight and in particular on the performance of the
O-rings used in the engines. Indeed, no test
had been performed at this temperature.
The following study takes up some of the analyses carried out that
night with the objective of assessing the potential influence of
the temperature and pressure to which the O-rings are subjected
on their probability of malfunction. Our starting point is
the results of the experiments carried out by NASA engineers
during the six years preceding the launch of the shuttle
Challenger.
* Loading the data
We start by loading this data:
#+begin_src python :results value :session *python* :exports both
import numpy as np
import pandas as pd
data = pd.read_csv("shuttle.csv")
data
#+end_src
#+RESULTS:
#+begin_example
Date Count Temperature Pressure Malfunction
0 4/12/81 6 66 50 0
1 11/12/81 6 70 50 1
2 3/22/82 6 69 50 0
3 11/11/82 6 68 50 0
4 4/04/83 6 67 50 0
5 6/18/82 6 72 50 0
6 8/30/83 6 73 100 0
7 11/28/83 6 70 100 0
8 2/03/84 6 57 200 1
9 4/06/84 6 63 200 1
10 8/30/84 6 70 200 1
11 10/05/84 6 78 200 0
12 11/08/84 6 67 200 0
13 1/24/85 6 53 200 2
14 4/12/85 6 67 200 0
15 4/29/85 6 75 200 0
16 6/17/85 6 70 200 0
17 7/29/85 6 81 200 0
18 8/27/85 6 76 200 0
19 10/03/85 6 79 200 0
20 10/30/85 6 75 200 2
21 11/26/85 6 76 200 0
22 1/12/86 6 58 200 1
#+end_example
The data set shows us the date of each test, the number of O-rings
(there are 6 on the main launcher), the
temperature (in Fahrenheit) and pressure (in psi), and finally the
number of identified malfunctions.
* Graphical inspection
Flights without incidents do not provide any information
on the influence of temperature or pressure on malfunction.
We thus focus on the experiments in which at least one O-ring was defective.
#+begin_src python :results value :session *python* :exports both
data = data[data.Malfunction>0]
data
#+end_src
#+RESULTS:
: Date Count Temperature Pressure Malfunction
: 1 11/12/81 6 70 50 1
: 8 2/03/84 6 57 200 1
: 9 4/06/84 6 63 200 1
: 10 8/30/84 6 70 200 1
: 13 1/24/85 6 53 200 2
: 20 10/30/85 6 75 200 2
: 22 1/12/86 6 58 200 1
We have a high temperature variability but
the pressure is almost always 200, which should
simplify the analysis.
How does the frequency of failure vary with temperature?
#+begin_src python :results output file :var matplot_lib_filename="freq_temp_python.png" :exports both :session *python*
import matplotlib.pyplot as plt
plt.clf()
data["Frequency"]=data.Malfunction/data.Count
data.plot(x="Temperature",y="Frequency",kind="scatter",ylim=[0,1])
plt.grid(True)
plt.savefig(matplot_lib_filename)
print(matplot_lib_filename)
#+end_src
#+RESULTS:
[[file:freq_temp_python.png]]
At first glance, the dependence does not look very important, but let's try to
estimate the impact of temperature $t$ on the probability of O-ring malfunction.
* Estimation of the temperature influence
Suppose that each of the six O-rings is damaged with the same
probability and independently of the others and that this probability
depends only on the temperature. If $p(t)$ is this probability, the
number $D$ of malfunctioning O-rings during a flight at
temperature $t$ follows a binomial law with parameters $n=6$ and
$p=p(t)$. To link $p(t)$ to $t$, we will therefore perform a
logistic regression.
#+begin_src python :results value :session *python* :exports both
import statsmodels.api as sm
data["Success"]=data.Count-data.Malfunction
data["Intercept"]=1
# logit_model=sm.Logit(data["Frequency"],data[["Intercept","Temperature"]]).fit()
logmodel=sm.GLM(data['Frequency'], data[['Intercept','Temperature']], family=sm.families.Binomial(sm.families.links.logit)).fit()
logmodel.summary()
#+end_src
#+RESULTS:
#+begin_example
Generalized Linear Model Regression Results
==============================================================================
Dep. Variable: Frequency No. Observations: 7
Model: GLM Df Residuals: 5
Model Family: Binomial Df Model: 1
Link Function: logit Scale: 1.0
Method: IRLS Log-Likelihood: -3.6370
Date: Fri, 20 Jul 2018 Deviance: 3.3763
Time: 16:56:08 Pearson chi2: 0.236
No. Iterations: 5
===============================================================================
coef std err z P>|z| [0.025 0.975]
-------------------------------------------------------------------------------
Intercept -1.3895 7.828 -0.178 0.859 -16.732 13.953
Temperature 0.0014 0.122 0.012 0.991 -0.238 0.240
===============================================================================
#+end_example
The most likely estimator of the temperature parameter is 0.0014
and the standard error of this estimator is 0.122, in other words we
cannot distinguish any particular impact and we must take our
estimates with caution.
* Estimation of the probability of O-ring malfunction
The expected temperature on the take-off day is 31°F. Let's try to
estimate the probability of O-ring malfunction at
this temperature from the model we just built:
#+begin_src python :results output file :var matplot_lib_filename="proba_estimate_python.png" :exports both :session *python*
import matplotlib.pyplot as plt
data_pred = pd.DataFrame({'Temperature': np.linspace(start=30, stop=90, num=121), 'Intercept': 1})
data_pred['Frequency'] = logmodel.predict(data_pred[['Intercept','Temperature']])
data_pred.plot(x="Temperature",y="Frequency",kind="line",ylim=[0,1])
plt.scatter(x=data["Temperature"],y=data["Frequency"])
plt.grid(True)
plt.savefig(matplot_lib_filename)
print(matplot_lib_filename)
#+end_src
#+RESULTS:
[[file:proba_estimate_python.png]]
As expected from the initial data, the
temperature has no significant impact on the probability of failure of the
O-rings. It will be about 0.2, as in the tests
where we had a failure of at least one joint. Let's get back to the initial dataset to estimate the probability of failure:
#+begin_src python :results output :session *python* :exports both
data = pd.read_csv("shuttle.csv")
print(np.sum(data.Malfunction)/np.sum(data.Count))
#+end_src
#+RESULTS:
: 0.06521739130434782
This probability is thus about $p=0.065$. Knowing that there is
a primary and a secondary O-ring on each of the three parts of the
launcher, the probability of failure of both joints of a launcher
is $p^2 \approx 0.00425$. The probability of failure of any one of the
launchers is $1-(1-p^2)^3 \approx 1.2%$. That would really be
bad luck.... Everything is under control, so the takeoff can happen
tomorrow as planned.
But the next day, the Challenger shuttle exploded and took away
with her the seven crew members. The public was shocked and in
the subsequent investigation, the reliability of the
O-rings was questioned. Beyond the internal communication problems
of NASA, which have a lot to do with this fiasco, the previous analysis
includes (at least) a small problem.... Can you find it?
You are free to modify this analysis and to look at this dataset
from all angles in order to to explain what's wrong.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment