1ere correction

parent 9cd0cbaa
......@@ -4,28 +4,16 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# toy_notebook_fr\n",
"# **À propos du calcul de $\\pi$** \n",
"\n",
"## **En demandant à la lib maths**\n",
"\n",
"\n",
"\n",
"March 28, 2019"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"1. **À propos du calcul de π** \n",
"\n",
"1.1. **En demandant à la lib maths**\n",
"\n",
"Mon ordinateur m’indique que π vaut *approximativement*"
"Mon ordinateur m’indique que $\\pi$ vaut *approximativement*"
]
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 5,
"metadata": {},
"outputs": [
{
......@@ -37,7 +25,7 @@
}
],
"source": [
"In [1]: from math import *\n",
"from math import *\n",
"print(pi)"
]
},
......@@ -46,14 +34,14 @@
"metadata": {},
"source": [
" \n",
"1.2. **En utilisant la méthode des aiguilles de Buffon**\n",
"## **En utilisant la méthode des aiguilles de Buffon**\n",
"\n",
"Mais calculé avec la **méthode** des [aiguilles de Buffon](https://fr.wikipedia.org/wiki/Aiguille_de_Buffon), on obtiendrait comme **approximation** :"
]
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 6,
"metadata": {},
"outputs": [
{
......@@ -62,13 +50,13 @@
"3.128911138923655"
]
},
"execution_count": 2,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"In [2]: import numpy as np\n",
"import numpy as np\n",
"np.random.seed(seed=42)\n",
"N = 10000\n",
"x = np.random.uniform(size=N, low=0, high=1)\n",
......@@ -81,16 +69,16 @@
"metadata": {},
"source": [
" \n",
"1.3. **Avec un argument \"fréquentiel\" de surface**\n",
"## **Avec un argument \"fréquentiel\" de surface**\n",
"\n",
"Sinon, une méthode plus simple à comprendre et ne faisant pas intervenir d’appel à la fonction \n",
"sinus se base sur le fait que si X ∼ U(0, 1) et Y ∼ U(0, 1) alors P\\[X2 + Y2 ≤ 1\\] = π/4 (voir \n",
"sinus se base sur le fait que si $X\\sim U(0, 1)$ et $Y\\sim U(0, 1)$ alors $P[X^2 + Y^2\\leq 1] = \\pi/4$ (voir \n",
"[méthode de Monte Carlo sur Wikipedia](https://fr.wikipedia.org/wiki/M%C3%A9thode_de_Monte-Carlo#D%C3%A9termination_de_la_valeur_de_%CF%80)). Le code suivant illustre ce fait :"
]
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 7,
"metadata": {},
"outputs": [
{
......@@ -107,7 +95,7 @@
}
],
"source": [
"In [3]: %matplotlib inline\n",
"%matplotlib inline\n",
"import matplotlib.pyplot as plt\n",
"np.random.seed(seed=42)\n",
"N = 1000\n",
......@@ -125,13 +113,13 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Il est alors aisé d’obtenir une approximation (pas terrible) de π en comptant combien de fois, \n",
"en moyenne, X2 + Y2 est inférieur à 1 :"
"Il est alors aisé d’obtenir une approximation (pas terrible) de $\\pi$ en comptant combien de fois, \n",
"en moyenne, $X^2 +Y^2$ est inférieur à 1 :"
]
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 8,
"metadata": {},
"outputs": [
{
......@@ -140,14 +128,21 @@
"3.112"
]
},
"execution_count": 4,
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"In [4]: 4*np.mean(accept)"
"4*np.mean(accept)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
......
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