correction mais toujours pas le bon résultat pour Buffon

parent b1cc0cea
...@@ -4,7 +4,13 @@ ...@@ -4,7 +4,13 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"# A propos de $\\pi$\n", "# À propos de $\\pi$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## En demandant à la librairie maths\n", "## En demandant à la librairie maths\n",
"Mon ordinateur m’indique que $\\pi$ vaut approximativement" "Mon ordinateur m’indique que $\\pi$ vaut approximativement"
] ]
...@@ -26,7 +32,7 @@ ...@@ -26,7 +32,7 @@
], ],
"source": [ "source": [
"from math import *\n", "from math import *\n",
"print(pi)\n" "print(pi)"
] ]
}, },
{ {
...@@ -34,7 +40,7 @@ ...@@ -34,7 +40,7 @@
"metadata": {}, "metadata": {},
"source": [ "source": [
"## En utilisant la méthode des aiguilles de Buffon\n", "## En utilisant la méthode des aiguilles de Buffon\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__ :"
] ]
}, },
{ {
...@@ -55,12 +61,11 @@ ...@@ -55,12 +61,11 @@
], ],
"source": [ "source": [
"import numpy as np\n", "import numpy as np\n",
"from math import *\n",
"np.random.seed(seed=42)\n", "np.random.seed(seed=42)\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",
"2/(sum((x+np.sin(theta))>1)/N)\n" "2/(sum((x+np.sin(theta))>1)/N)"
] ]
}, },
{ {
...@@ -134,13 +139,6 @@ ...@@ -134,13 +139,6 @@
"source": [ "source": [
"4*np.mean(accept)" "4*np.mean(accept)"
] ]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
} }
], ],
"metadata": { "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