v3

parent e1255a3c
...@@ -11,8 +11,7 @@ ...@@ -11,8 +11,7 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"## 1.1 En demandant à la lib maths\n", "## En demandant à la lib maths\n",
"\n",
"Mon ordinateur m’indique que π vaut *approximativement*" "Mon ordinateur m’indique que π vaut *approximativement*"
] ]
}, },
...@@ -38,9 +37,8 @@ ...@@ -38,9 +37,8 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"## 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__ :"
"Mais calculé avec la **méthode** des [aiguilles de Buffon](https://fr.wikipedia.org/wiki/Aiguille_de_Buffon), on obtiendrait comme **approximation** :"
] ]
}, },
{ {
...@@ -61,22 +59,18 @@ ...@@ -61,22 +59,18 @@
], ],
"source": [ "source": [
"import numpy as np\n", "import numpy as np\n",
"\n",
"np.random.seed(seed=42)\n", "np.random.seed(seed=42)\n",
"\n",
"N = 10000\n", "N = 10000\n",
"x = np.random.uniform(size=N, low=0, high=1)\n", "x = np.random.uniform(size=N, low=0, high=1)\n",
"theta = np.random.uniform(size=N, low=0, high=pi/2)\n", "theta = np.random.uniform(size=N, low=0, high=pi/2)\n",
"\n", "2/(sum((x + np.sin(theta))>1)/N)"
"2 / (sum((x + np.sin(theta)) > 1) / N)"
] ]
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"## 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", "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 \\sim U(0,1)$ et $Y \\sim U(0,1)$ alors \n", "sinus se base sur le fait que si $X \\sim U(0,1)$ et $Y \\sim U(0,1)$ alors \n",
"$P[X^2 + Y^2 \\leq 1] = \\pi/4$ (voir [méthode de Monte Carlo sur Wikipedia](https://fr.wikipedia.org/wiki/Méthode_de_Monte-Carlo#Détermination_de_la_valeur_de_π)). Le code suivant illustre ce fait :" "$P[X^2 + Y^2 \\leq 1] = \\pi/4$ (voir [méthode de Monte Carlo sur Wikipedia](https://fr.wikipedia.org/wiki/Méthode_de_Monte-Carlo#Détermination_de_la_valeur_de_π)). Le code suivant illustre ce fait :"
...@@ -84,7 +78,7 @@ ...@@ -84,7 +78,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": 3,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -105,7 +99,6 @@ ...@@ -105,7 +99,6 @@
"import matplotlib.pyplot as plt\n", "import matplotlib.pyplot as plt\n",
"\n", "\n",
"np.random.seed(seed=42)\n", "np.random.seed(seed=42)\n",
"\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",
...@@ -129,7 +122,7 @@ ...@@ -129,7 +122,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": 4,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -138,7 +131,7 @@ ...@@ -138,7 +131,7 @@
"3.112" "3.112"
] ]
}, },
"execution_count": 5, "execution_count": 4,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
......
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