From 12a61744a8d7fd13f9f51a0c1bf3ac32e70bcb03 Mon Sep 17 00:00:00 2001 From: escuiller Date: Thu, 23 Apr 2020 19:03:35 +0200 Subject: [PATCH] =?UTF-8?q?deuxi=C3=A8me=20essai=20de=20commit=20avec=20ma?= =?UTF-8?q?git=20......?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module2/exo1/toy_document_orgmode_python_fr.org | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/module2/exo1/toy_document_orgmode_python_fr.org b/module2/exo1/toy_document_orgmode_python_fr.org index ddf00d7..448fad8 100644 --- a/module2/exo1/toy_document_orgmode_python_fr.org +++ b/module2/exo1/toy_document_orgmode_python_fr.org @@ -1,4 +1,4 @@ -#+TITLE: Votre titre +#+TITLE: À propos du calcul de Pi #+AUTHOR: Votre nom #+DATE: La date du jour #+LANGUAGE: fr @@ -38,11 +38,10 @@ print(2/(sum((x+np.sin(theta))>1)/N)) * 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[X2+Y2≤1]=π/4 (voir [[méthode de Monte -Carlo sur -Wikipédia][https://fr.wikipedia.org/wiki/M%C3%A9thode_de_Monte-Carlo#D%C3%A9termination_de_la_valeur_de_%CF%80]]). Le -code suivant illustre ce fait : -#+begin_src python :results file :session :var matplot_lib_filename="figure.png" :exports both +X∼U(0,1) et Y∼U(0,1) alors P[X2+Y2≤1]=π/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 Wikipédia]]). Le code suivant illustre ce fait : +#+begin_src python :results file :session :var matplot_lib_filename="./figure.png" :exports both import matplotlib.pyplot as plt np.random.seed(seed=42) @@ -61,8 +60,7 @@ ax.set_aspect('equal') plt.savefig(matplot_lib_filename) print(matplot_lib_filename) #+end_src - -#+RESULTS: +[[./figure.png]] Il est alors aisé d'obtenir une approximation (pas terrible) de π en comptant combien de fois, en moyenne, X2+Y2 est inférieur à 1 : -- 2.18.1