From 62610cf354c76d934b437e910d2d87d6ab22f281 Mon Sep 17 00:00:00 2001 From: 036332d1e8a8fad18eace193f300e27a <036332d1e8a8fad18eace193f300e27a@app-learninglab.inria.fr> Date: Fri, 20 Jun 2025 02:06:32 +0000 Subject: [PATCH] Pi estimate- Added Notes --- module2/exo1/toy_notebook_fr.ipynb | 34 +++++++++++++++++++----------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/module2/exo1/toy_notebook_fr.ipynb b/module2/exo1/toy_notebook_fr.ipynb index 1ac5add..c806c93 100644 --- a/module2/exo1/toy_notebook_fr.ipynb +++ b/module2/exo1/toy_notebook_fr.ipynb @@ -4,23 +4,17 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# À propos de pi" + "### Estimating π\n", + "\n", + "I tried to compute pi using Buffon’s Needle method with random numbers to estimate the value of π. \n", + "The result is close to 3.14, showing how randomness can be used in simulations." ] }, { - "cell_type": "code", - "execution_count": 1, + "cell_type": "markdown", "metadata": {}, - "outputs": [], "source": [ - "from random import random \n", - "N=10000\n", - "val=sum(\n", - "1 for _ in range(N)\n", - " if random()**2 + random()**2 <= 1\n", - ")\n", - "\n", - "pi_estimate = 4 * val / N" + "# About Pi" ] }, { @@ -34,6 +28,22 @@ "Donc : $\\pi \\approx 4 \\times \\frac{\\text{points dans le cercle}}{\\text{points totaux}}$\n" ] }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "from random import random \n", + "N=10000\n", + "val=sum(\n", + "1 for _ in range(N)\n", + " if random()**2 + random()**2 <= 1\n", + ")\n", + "\n", + "pi_estimate = 4 * val / N" + ] + }, { "cell_type": "code", "execution_count": 8, -- 2.18.1