Commit 57d3b550 authored by Olivia Guillin's avatar Olivia Guillin

Troisème_essai

parent ef266ddd
......@@ -21,7 +21,6 @@ pi
: 3.141592653589793
* En utilisant la méthode des aiguilles de Buffon
SCHEDULED: <2020-04-24 Ven>
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 :exports both
......@@ -42,7 +41,7 @@ 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 \le1] = \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 file :session :var matplot_lib_filename="figure_pi_mc2.png" :exports both
#+begin_src python :results output file :var matplot_lib_filename="figure_pi_mc2.png" :exports both :session *python*
import matplotlib.pyplot as plt
np.random.seed(seed=42)
......@@ -63,7 +62,11 @@ print(matplot_lib_filename)
#+end_src
#+RESULTS:
[[file:<matplotlib.collections.PathCollection object at 0x1145ee250>]]
[[file:Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/var/folders/21/wtvjlyxj21b3gj703l4k0j_40000gp/T/babel-4uvhkJ/python-bYwGgQ", line 4, in <module>
np.random.seed(seed=42)
NameError: name 'np' is not defined]]
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 :
......
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