diff --git a/module2/exo1/toy_document_orgmode_python_fr.org b/module2/exo1/toy_document_orgmode_python_fr.org index ddf00d7afe5d02940cf7184cdb3b853ccc4240b5..448fad8b34be888fd8b1dedf046f95ef88388df2 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 :