Commit 8ee13f65 authored by Émile Jetzer's avatar Émile Jetzer 🎱

Corrections après avoir vu le corrigé

parent 33c48a1c
......@@ -15,7 +15,7 @@
Mon ordinateur m'indique que \(\pi\) vaut /approximativement/:
#+begin_src python :export both :session "Python"
#+begin_src python :results value :session "Python" :exports both
import math
math.pi
#+end_src
......@@ -29,7 +29,7 @@ Mais calculé avec la *méthode* des [aiguilles de
Buffon](https://fr.wikipedia.org/wiki/Aiguille_de_Buffon), on
obtiendrait comme *approximation*:
#+begin_src python :session "Python"
#+begin_src python :results value :session "Python" :exports both
import numpy as np
np.random.seed(seed=42)
N=10000
......@@ -50,7 +50,7 @@ intervenir d'appel à la fonction sinus se base sur le fait que si
Wikipedia](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 :session "Python" :export both
#+begin_src python :results output file :var matplot_lib_filename="figure_pi_mc2.png" :session "Python" :exports both
import matplotlib.pyplot as plt
np.random.seed(seed=42)
......@@ -71,15 +71,21 @@ print(matplot_lib_filename)
#+end_src
#+RESULTS:
: <matplotlib.collections.PathCollection object at 0x11abb2940>
[[file:]]
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:
#+begin_src python :session "Python"
#+begin_src python :results output :session "Python" :exports both
4*np.mean(accept)
#+end_src
#+RESULTS:
: 3.112
:
:
]]
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