From e923bec1fe2eac2da015e4b8e78353f5ee102907 Mon Sep 17 00:00:00 2001 From: 9dadadddfac1a9d04ec9b816578a2d8f <9dadadddfac1a9d04ec9b816578a2d8f@app-learninglab.inria.fr> Date: Mon, 28 Oct 2024 13:29:53 +0000 Subject: [PATCH] no commit message --- module2/exo1/toy_notebook_fr.ipynb | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/module2/exo1/toy_notebook_fr.ipynb b/module2/exo1/toy_notebook_fr.ipynb index fdc8f5b..2a4e150 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, -- 2.18.1