From d9c2f96f929d83e5a63534e509e4a1bc8e6c6ffa Mon Sep 17 00:00:00 2001 From: 289230ab50cb5ba43830fe6a40fb0cae <289230ab50cb5ba43830fe6a40fb0cae@app-learninglab.inria.fr> Date: Thu, 19 Oct 2023 12:23:35 +0000 Subject: [PATCH] (Useless) Edit metadata --- module2/exo1/toy_notebook_en.ipynb | 40 ++++++++++++++++-------------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/module2/exo1/toy_notebook_en.ipynb b/module2/exo1/toy_notebook_en.ipynb index e58cc6f..3f97c46 100644 --- a/module2/exo1/toy_notebook_en.ipynb +++ b/module2/exo1/toy_notebook_en.ipynb @@ -4,22 +4,26 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# On the computation of $\\pi$" + "# On the computation of $\\pi$" ] }, { "cell_type": "markdown", - "metadata": {}, + "metadata": { + "hideCode": false + }, "source": [ "## Asking the maths library\n", - "\n", "My computer tells me that π is *approximatively*" ] }, { "cell_type": "code", "execution_count": 1, - "metadata": {}, + "metadata": { + "hideCode": false, + "hidePrompt": false + }, "outputs": [ { "name": "stdout", @@ -36,17 +40,21 @@ }, { "cell_type": "markdown", - "metadata": {}, + "metadata": { + "hidePrompt": false + }, "source": [ "## Buffon's needle\n", - "\n", "Applying the method of [Buffon’s needle](https://en.wikipedia.org/wiki/Buffon%27s_needle_problem), we get the **approximation**" ] }, { "cell_type": "code", "execution_count": 2, - "metadata": {}, + "metadata": { + "hideCode": false, + "hidePrompt": false + }, "outputs": [ { "data": { @@ -70,10 +78,11 @@ }, { "cell_type": "markdown", - "metadata": {}, + "metadata": { + "hideCode": false + }, "source": [ "## Using a surface fraction argument\n", - "\n", "A method that is easier to understand and does not make use of the sin function is based on the fact that if $X \\sim U(0, 1)$ and $Y \\sim U(0, 1)$, then $P[X^2 + Y^2 \\leq 1] = \\pi/4$ (see [\"Monte Carlo method\" on Wikipedia](https://en.wikipedia.org/wiki/Monte_Carlo_method)). The following code uses this approach:" ] }, @@ -98,11 +107,12 @@ "source": [ "%matplotlib inline\n", "import matplotlib.pyplot as plt\n", + "\n", "np.random.seed(seed=42)\n", "N = 1000\n", "x = np.random.uniform(size=N, low=0, high=1)\n", "y = np.random.uniform(size=N, low=0, high=1)\n", - "1\n", + "\n", "accept = (x*x+y*y) <= 1\n", "reject = np.logical_not(accept)\n", "fig, ax = plt.subplots(1)\n", @@ -137,16 +147,10 @@ "source": [ "4*np.mean(accept)" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { + "celltoolbar": "Hide code", "kernelspec": { "display_name": "Python 3", "language": "python", @@ -162,7 +166,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.6.2" } }, "nbformat": 4, -- 2.18.1