From 6df2878ab7d7aa33a2a917578f3a105bb4b1a6b6 Mon Sep 17 00:00:00 2001 From: fe77b5323a938dbf30e79610829bed48 Date: Thu, 26 Nov 2020 16:57:37 +0000 Subject: [PATCH] =?UTF-8?q?Avance=20jusqu'=C3=A0=201.3=20non=20inclut?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module2/exo1/toy_notebook_fr.ipynb | 48 +++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/module2/exo1/toy_notebook_fr.ipynb b/module2/exo1/toy_notebook_fr.ipynb index 01b105d..73dcd38 100644 --- a/module2/exo1/toy_notebook_fr.ipynb +++ b/module2/exo1/toy_notebook_fr.ipynb @@ -4,23 +4,21 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# toy_notebook_fr" + "# A propos du calcul de $\\pi$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "## March 28,2019\n" + "## En demandant à la lib maths" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "1.A propos du calcul de :pi:\n", - "1.1 En demandant à la lib maths\n", - "Mon ordinateur m'indique que :pi: vaut *approximativement*" + "Mon ordinateur m'indique que $\\pi$ vaut *approximativement*" ] }, { @@ -41,12 +39,46 @@ "print(pi)" ] }, + { + "cell_type": "markdown", + "metadata": { + "hideOutput": true + }, + "source": [ + "## En utilisant la méthode des aiguilles de Buffon" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Mais calculé avec la **méthode** des aiguilles de Buffon, on obtiendrait comme **approximation** :" + ] + }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "data": { + "text/plain": [ + "3.128911138923655" + ] + }, + "execution_count": 3, + "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)" + ] } ], "metadata": { -- 2.18.1