diff --git a/module2/exo1/toy_notebook_fr.ipynb b/module2/exo1/toy_notebook_fr.ipynb index 647bab822f1c378cbfe7dd8a4bdcfbec153b4d73..820ac4151e1987998215c07467bb0e28457679a8 100644 --- a/module2/exo1/toy_notebook_fr.ipynb +++ b/module2/exo1/toy_notebook_fr.ipynb @@ -36,6 +36,31 @@ "Mais calculé avec la __méthode__ des [aiguilles de Buffon](https://fr.wikipedia.org/wiki/Aiguille_de_Buffon), on obtiendrait comme __approximation__ :\n" ] }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "3.128911138923655" + ] + }, + "execution_count": 2, + "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,