no commit message

parent 604f2b8d
...@@ -102,14 +102,17 @@ ...@@ -102,14 +102,17 @@
} }
], ],
"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",
"\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",
...@@ -120,8 +123,8 @@ ...@@ -120,8 +123,8 @@
"cell_type": "markdown", "cell_type": "markdown",
"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 $\\pi$ 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