From 7dfa46580d335bfbe0852ef0fe2eff77718e3b9b Mon Sep 17 00:00:00 2001 From: 99d292aec7079aad242d36ac4efbad08 <99d292aec7079aad242d36ac4efbad08@app-learninglab.inria.fr> Date: Tue, 7 Apr 2020 19:51:53 +0000 Subject: [PATCH] Update toy_document_orgmode_python_fr.org --- module2/exo1/toy_document_orgmode_python_fr.org | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/module2/exo1/toy_document_orgmode_python_fr.org b/module2/exo1/toy_document_orgmode_python_fr.org index 177a5c7..b03de48 100644 --- a/module2/exo1/toy_document_orgmode_python_fr.org +++ b/module2/exo1/toy_document_orgmode_python_fr.org @@ -22,7 +22,7 @@ pi : 3.141592653589793 * En utilisant la méthode des aiguilles de Buffon -Mais calculé avec la *méthode* des [[https://fr.wikipedia.org/wiki/Aiguille_de_Buffon][aiguilles de Buffon]], on obtiendrait +Mais calculé avec la *méthode* des [[https://fr.wikipedia.org/wiki/Aiguille_de_Buffon][aiguilles de Buffon]], on obtiendrait comme *approximation* : #+begin_src python :results value :session *python* :exports both @@ -40,9 +40,9 @@ theta = np.random.uniform(size=N, low=0, high=pi/2) * 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\sim U(0,1)$ et $Y\sim U(0,1)$ alors $P[X^2+Y^2 \leq1]=\pi/4$ (voir [[https://fr.wikipedia.org/wiki/M%2525C3%2525A9thode_de_Monte-Carlo#D%2525C3%2525A9termination_de_la_valeur_de_%2525CF%252580][méthode +$X\sim U(0,1)$ et $Y\sim U(0,1)$ alors $P[X^2+Y^2 \leq1]=\pi/4$ (voir [[https://fr.wikipedia.org/wiki/M%25C3%25A9thode_de_Monte-Carlo#D%25C3%25A9termination_de_la_valeur_de_%25CF%2580][méthode de -Monte Carlo sur Wikipedia]]). Le code suivant illustre ce fait : +Monte Carlo sur Wikipedia]]). Le code suivant illustre ce fait : #+begin_src python :results output file :var matplot_lib_filename="figure_pi_mc2.png" :exports both :session *python* import matplotlib.pyplot as plt @@ -69,6 +69,7 @@ print(matplot_lib_filename) Il est alors aisé d'obtenir une approximation (pas terrible) de $\pi$ en comptant combien de fois, en moyenne, $X^2 + Y^2$ est inférieur à 1 : + #+begin_src python :results output :session *python* :exports both 4*np.mean(accept) #+end_src -- 2.18.1