From 1fca77a87b2947e7ab898cebe825e178338c4886 Mon Sep 17 00:00:00 2001 From: 3d1cde3613956104173df2e357578f04 <3d1cde3613956104173df2e357578f04@app-learninglab.inria.fr> Date: Sun, 3 May 2020 12:51:33 +0000 Subject: [PATCH] =?UTF-8?q?aiguille=20de=20Buffon=20et=20explication=20m?= =?UTF-8?q?=C3=A9thode=20fr=C3=A9quentiste?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module2/exo1/toy_notebook_fr.ipynb | 55 ++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/module2/exo1/toy_notebook_fr.ipynb b/module2/exo1/toy_notebook_fr.ipynb index a148a05..f310ca5 100644 --- a/module2/exo1/toy_notebook_fr.ipynb +++ b/module2/exo1/toy_notebook_fr.ipynb @@ -39,6 +39,61 @@ "print(pi)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "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](https://fr.wikipedia.org/wiki/Aiguille_de_Buffon), on obtiendrait comme **approximation** :" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "3.128911138923655" + ] + }, + "execution_count": 2, + "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)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Avec un argument \"fréquentiel\" de surface" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Sinon, une méthode plus simple à comprendre et ne faisant pas intervenir d’appel à la fonction\n", + "sinus se base sur le fait que si $X ∼ U(0, 1)$ et $Y ∼ U(0, 1)$ alors $P[X^2 + Y^2 ≤ 1] = \\pi/4$ (voir\n", + "[méthode de Monte Carlo sur Wikipedia](https://fr.wikipedia.org/wiki/M%C3%A9thode_de_Monte-Carlo)). Le code suivant illustre ce fait :" + ] + }, { "cell_type": "code", "execution_count": null, -- 2.18.1