From 707a6e4ea193939b4adfcb52e7c410a664bd80e7 Mon Sep 17 00:00:00 2001 From: 3647d0b8ed16292ade589331f0d6145a <3647d0b8ed16292ade589331f0d6145a@app-learninglab.inria.fr> Date: Thu, 10 Dec 2020 10:40:06 +0000 Subject: [PATCH] test4 --- module2/exo1/toy_notebook_fr.ipynb | 49 +++++++++++------------------- 1 file changed, 18 insertions(+), 31 deletions(-) diff --git a/module2/exo1/toy_notebook_fr.ipynb b/module2/exo1/toy_notebook_fr.ipynb index 00c8330..6f4d1da 100644 --- a/module2/exo1/toy_notebook_fr.ipynb +++ b/module2/exo1/toy_notebook_fr.ipynb @@ -59,7 +59,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 16, "metadata": {}, "outputs": [ { @@ -68,7 +68,7 @@ "3.128911138923655" ] }, - "execution_count": 15, + "execution_count": 16, "metadata": {}, "output_type": "execute_result" } @@ -87,48 +87,35 @@ "metadata": {}, "source": [ "## Avec un argument \"fréquentiel\" de surface\n", - "Sinon une méthode plus simple à comprendre et ne faisant par intervenir d'appel à la fonction sinus se base sur le fait si $X\\sim U(0,1)$ et $Y\\sim U(0,1)$ alors $P[X^2+Y^2\\leq 1] = \\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 : " + "Sinon une méthode plus simple à comprendre et ne faisant par 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\\leq 1] = \\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 : " ] }, { "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [], - "source": [ - "%matplotlib inline\n", - "import matplotlib.pyplot as plt" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [], - "source": [ - "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", - "accept=(x*x+y*y)<=1\n", - "reject=np.logical_not(accept)" - ] - }, - { - "cell_type": "code", - "execution_count": 9, + "execution_count": 17, "metadata": {}, "outputs": [ { "ename": "SyntaxError", - "evalue": "positional argument follows keyword argument (, line 2)", + "evalue": "positional argument follows keyword argument (, line 13)", "output_type": "error", "traceback": [ - "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m2\u001b[0m\n\u001b[0;31m ax.scatter(x[accept], y[accept], c='b', alpha=0,2, edgecolor=None)\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m positional argument follows keyword argument\n" + "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m13\u001b[0m\n\u001b[0;31m ax.scatter(x[accept], y[accept], c='b', alpha=0,2, edgecolor=None)\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m positional argument follows keyword argument\n" ] } ], "source": [ + "%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", + "\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", @@ -139,7 +126,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Il est alors aisé d'obtenir une approximation (pas terrible) de *π* en comptant combien de fois, en moyenne, X²+Y² est inférieur à 1 : " + "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 : " ] }, { -- 2.18.1