Commit e8897524 authored by antoine_moniot's avatar antoine_moniot

Add change to show the figure.

parent e6c4f5c8
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
#+HTML_HEAD: <script type="text/javascript" src="http://www.pirilampo.org/styles/lib/js/jquery.stickytableheaders.js"></script> #+HTML_HEAD: <script type="text/javascript" src="http://www.pirilampo.org/styles/lib/js/jquery.stickytableheaders.js"></script>
#+HTML_HEAD: <script type="text/javascript" src="http://www.pirilampo.org/styles/readtheorg/js/readtheorg.js"></script> #+HTML_HEAD: <script type="text/javascript" src="http://www.pirilampo.org/styles/readtheorg/js/readtheorg.js"></script>
#+TOC: headlines 1
* En demandant à lib maths * En demandant à lib maths
Mon ordinateur m'indique que π vaut /approximativement/: Mon ordinateur m'indique que π vaut /approximativement/:
...@@ -47,7 +49,7 @@ intervenir d'appel à la fonction sinus se base sur le fait que si ...@@ -47,7 +49,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 ≤ 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 $X \sim U(0, 1)$ et $Y \sim U(0, 1)$ alors $P[X^2 + Y^2 ≤ 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 Wikipedia]]). Le code suivant illustre ce fait : de Monte Carlo sur Wikipedia]]). Le code suivant illustre ce fait :
#+begin_src python :results file :session :var matplot_lib_filename="./figure.png" :exports both #+begin_src python :results output file :session :var matplot_lib_filename="./figure.png" :exports both
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
np.random.seed(seed=42) np.random.seed(seed=42)
...@@ -68,7 +70,8 @@ print(matplot_lib_filename) ...@@ -68,7 +70,8 @@ print(matplot_lib_filename)
#+end_src #+end_src
#+RESULTS: #+RESULTS:
[[file:<matplotlib.collections.PathCollection object at 0x7f337d1964f0>]] [[file:./figure.png]]
Il est alors aisé d'obtenir une approximation (pas terrible) de π en Il est alors aisé d'obtenir une approximation (pas terrible) de π en
comptant combien de fois, en moyenne, $X^2 + Y^2$ est inférieur à $1$ : 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