Update 3

parent 71430447
......@@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# A propos du calcul de π"
"# A propos du calcul de $\\pi$"
]
},
{
......@@ -12,7 +12,7 @@
"metadata": {},
"source": [
"## En demandant à la lib maths\n",
"Mon ordinateur m'indique que π vaut *approximativement*"
"Mon ordinateur m'indique que $\\pi$ vaut *approximativement*"
]
},
{
......@@ -38,7 +38,7 @@
"metadata": {},
"source": [
"## En utilisant la méthode des aiguilles de Buffon\n",
"Mais calculé avec la __méthode__ [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__ :"
]
},
{
......@@ -93,15 +93,17 @@
}
],
"source": [
"%matplotlib inline\n",
"%matplotlib inline \n",
"import matplotlib.pyplot as plt\n",
"\n",
"np.random.seed(seed=42)\n",
"N = 1000\n",
"x = 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",
"reject = np.logical_not(accept)\n",
"\n",
"fig, ax = plt.subplots(1)\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",
......@@ -134,13 +136,6 @@
"source": [
"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