diff --git a/module2/exo1/toy_notebook_fr.ipynb b/module2/exo1/toy_notebook_fr.ipynb index fdc8f5b765be73f2af0be91275d110bd55669f17..2a4e1508eaac571d53e5756da9dbfa3ffaa295ac 100644 --- a/module2/exo1/toy_notebook_fr.ipynb +++ b/module2/exo1/toy_notebook_fr.ipynb @@ -13,7 +13,7 @@ "hideCode": true }, "source": [ - "## En demandant à la lib maths\n", + "# En demandant à la lib maths\n", "Mon ordinateur m’indique que $\\pi$ vaut *approximativement*" ] }, @@ -43,6 +43,31 @@ "Mais calculé avec la _méthode_ des [aiguilles de Buffon](https://fr.wikipedia.org/wiki/Aiguille_de_Buffon), on obtiendrait comme _approximation_ :" ] }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "3.128911138923655" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import numpy as np\n", + "np.random.seed(seed=42)\n", + "N = 10000\n", + "x = np.random.uniform(size=N, low=0, high=1)\n", + "theta = np.random.uniform(size=N, low=0, high=pi/2)\n", + "2/(sum((x+np.sin(theta))>1)/N)" + ] + }, { "cell_type": "code", "execution_count": null,