From 5f910f090238671c74f3f06d771d23173247329b Mon Sep 17 00:00:00 2001 From: Lucie Leonarski Date: Wed, 22 Jul 2020 20:57:03 +0200 Subject: [PATCH] =?UTF-8?q?Mon=20deuxi=C3=A8me=20commit=20magit=20pour=20l?= =?UTF-8?q?'exercice=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module2/exo1/toy_document_orgmode_python_fr.org | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/module2/exo1/toy_document_orgmode_python_fr.org b/module2/exo1/toy_document_orgmode_python_fr.org index b32a69d..af8b3eb 100644 --- a/module2/exo1/toy_document_orgmode_python_fr.org +++ b/module2/exo1/toy_document_orgmode_python_fr.org @@ -13,13 +13,14 @@ * En demandant à la lib maths -Mon ordinateur m'indique que \pi vaut approximativement: +Mon ordinateur m'indique que $\pi$ vaut approximativement: #+begin_src python :results output :session :exports both from math import * pi #+end_src +#+RESULTS: * En utilisant la méthode des aiguilles de Buffon @@ -34,10 +35,11 @@ theta = np.random.uniform(size=N, low=0, high=pi/2) 2/(sum((x+np.sin(theta))>1)/N) #+end_src +#+RESULTS: * Avec un argument "fréquentiel" de surface -Sinon, une méthode plus simple à comprendre et ne faisant pas intervenir d'appel à la fonction 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 [[https://fr.wikipedia.org/wiki/M%C3%A9thode_de_Monte-Carlo#D%C3%A9termination_de_la_valeur_de_%CF%80][méthode de Monte Carlo sur Wikipedia]]). Le code suivant illustre ce fait : +Sinon, une méthode plus simple à comprendre et ne faisant pas intervenir d'appel à la fonction sinus se base sur le fait que si $X \sim U(0,1)$ et $Y \sim U(0,1)$ alors $P[X^2+Y^2 ≤1]=\pi/4$ (voir [[https://fr.wikipedia.org/wiki/M%C3%A9thode_de_Monte-Carlo#D%C3%A9termination_de_la_valeur_de_%CF%80][méthode de Monte Carlo sur Wikipedia]]). Le code suivant illustre ce fait : #+begin_src python :results output file :session :var matplot_lib_filename="./random_uniform_pi.png" :exports results import matplotlib.pyplot as plt -- 2.18.1