File Completed Update 1

parent e9d8a18a
...@@ -11,9 +11,9 @@ ...@@ -11,9 +11,9 @@
"\n", "\n",
"<center>March 28, 2019</center>\n", "<center>March 28, 2019</center>\n",
" \n", " \n",
"# 1 À propos du calcul de *π*\n", "# 1 À propos du calcul de $\\pi$\n",
"## 1.1 En demandant à la lib maths\n", "## 1.1 En demandant à la lib maths\n",
"Mon ordinateur m’indique que *π* vaut *approximativement*\n" "Mon ordinateur m’indique que $\\pi$ vaut *approximativement*\n"
] ]
}, },
{ {
...@@ -21,7 +21,8 @@ ...@@ -21,7 +21,8 @@
"execution_count": 1, "execution_count": 1,
"metadata": { "metadata": {
"hideCode": false, "hideCode": false,
"hidePrompt": false "hidePrompt": false,
"scrolled": true
}, },
"outputs": [ "outputs": [
{ {
...@@ -42,7 +43,7 @@ ...@@ -42,7 +43,7 @@
"metadata": {}, "metadata": {},
"source": [ "source": [
"## 1.2 En utilisant la méthode des aiguilles de Buffon\n", "## 1.2 En utilisant la méthode des aiguilles de Buffon\n",
"Mais calculé avec la **méthode** des aiguilles de Buffon, on obtiendrait comme **approximation** :" "Mais calculé avec la __méthode__ des aiguilles de Buffon, on obtiendrait comme __Approximation__ :"
] ]
}, },
{ {
...@@ -76,7 +77,7 @@ ...@@ -76,7 +77,7 @@
"source": [ "source": [
"## 1.3 Avec un argument \"fréquentiel\" de surface\n", "## 1.3 Avec un argument \"fréquentiel\" de surface\n",
"Sinon, une méthode plus simple à comprendre et ne faisant pas intervenir d’appel à la fonction\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[X^2 + Y^2 ≤ 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 :" "[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 :"
] ]
}, },
...@@ -101,13 +102,15 @@ ...@@ -101,13 +102,15 @@
"source": [ "source": [
"%matplotlib inline\n", "%matplotlib inline\n",
"import matplotlib.pyplot as plt\n", "import matplotlib.pyplot as plt\n",
"\n",
"np.random.seed(seed=42)\n", "np.random.seed(seed=42)\n",
"N = 1000\n", "N = 1000\n",
"x = np.random.uniform(size=N, low=0, high=1)\n", "x = np.random.uniform(size=N, low=0, high=1)\n",
"y = np.random.uniform(size=N, low=0, high=1)\n", "y = np.random.uniform(size=N, low=0, high=1)\n",
"1\n", "\n",
"accept = (x*x+y*y) <= 1\n", "accept = (x*x+y*y) <= 1\n",
"reject = np.logical_not(accept)\n", "reject = np.logical_not(accept)\n",
"\n",
"fig, ax = plt.subplots(1)\n", "fig, ax = plt.subplots(1)\n",
"ax.scatter(x[accept], y[accept], c='b', alpha=0.2, edgecolor=None)\n", "ax.scatter(x[accept], y[accept], c='b', alpha=0.2, edgecolor=None)\n",
"ax.scatter(x[reject], y[reject], c='r', alpha=0.2, edgecolor=None)\n", "ax.scatter(x[reject], y[reject], c='r', alpha=0.2, edgecolor=None)\n",
...@@ -119,7 +122,7 @@ ...@@ -119,7 +122,7 @@
"metadata": {}, "metadata": {},
"source": [ "source": [
"Il est alors aisé d’obtenir une approximation (pas terrible) de π en comptant combien de fois,\n", "Il est alors aisé d’obtenir une approximation (pas terrible) de π en comptant combien de fois,\n",
"en moyenne, X^2 + Y^2 est inférieur à 1 :" "en moyenne, $X^2 + Y^2$ est inférieur à 1 :"
] ]
}, },
{ {
......
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