Commit 12a61744 authored by escuiller's avatar escuiller

deuxième essai de commit avec magit ......

parent f878df12
#+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 :
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment