From c4cec83a832bbb2ab61ca1dc7f605577a1b09e58 Mon Sep 17 00:00:00 2001 From: 7a8683a5f70a87b2c5d49e20ed9e6ac0 <7a8683a5f70a87b2c5d49e20ed9e6ac0@app-learninglab.inria.fr> Date: Tue, 2 Jul 2024 17:06:01 +0000 Subject: [PATCH] Adjusting the buffon example to print with the same precision as in the model document --- module2/exo1/toy_notebook_fr.ipynb | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/module2/exo1/toy_notebook_fr.ipynb b/module2/exo1/toy_notebook_fr.ipynb index adf8b9c..b5997ec 100644 --- a/module2/exo1/toy_notebook_fr.ipynb +++ b/module2/exo1/toy_notebook_fr.ipynb @@ -53,14 +53,11 @@ }, "outputs": [ { - "data": { - "text/plain": [ - "3.128911138923655" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" + "name": "stdout", + "output_type": "stream", + "text": [ + "3.1289111389236548\n" + ] } ], "source": [ @@ -69,7 +66,8 @@ "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)" + "approx = 2/(sum((x+np.sin(theta))>1)/N)\n", + "print(f\"{approx:.16f}\")" ] }, { -- 2.18.1