6

parent 2e1ae6cc
......@@ -10,7 +10,7 @@
"Mon ordinateur m'indique que $\\pi$ vaut *approximativement*\n",
"\n",
"\n",
"In [1]:\n",
"In \\[1]:\n",
"from math import *\n",
"print (pi)\n",
" \n",
......@@ -22,7 +22,7 @@
"obtiendrait comme **approximation** :\n",
"\n",
"\n",
"In [2]:\n",
"In \\[2]:\n",
"import numpy as np\n",
"np.random.seed(seed=42)\n",
"N = 10000\n",
......@@ -36,7 +36,7 @@
"Sinon, une méthode plus simple à comprendre et ne faisant pas intervenir d'appel à la fonction 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\\leq1] = \\pi/4$ (voir [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 :\n",
"\n",
"\n",
"In [3]:\n",
"In \\[3]:\n",
"\n",
"%matplotlib inline\n",
"import matplotlib.pyplot as plt\n",
......@@ -57,7 +57,7 @@
"Il est alors aisé d'obtenir une approximation (pas terrible) de $\\pi$ en comptant combien de fois, en moyenne, $X^2 + Y^2$ est inférieur à 1 :\n",
"\n",
"\n",
"In [4]:\n",
"In \\[4]:\n",
"\n",
"4*np.mean(accept)\n",
"3.1120000000000001\n",
......
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