diff --git a/module2/exo1/toy_document_orgmode_python_en.org b/module2/exo1/toy_document_orgmode_python_en.org index f7db6dcc2f27482ee826932de6c64a6caf090705..d30e67bb8f1d7e3c24f650eb013919d1fb285df2 100644 --- a/module2/exo1/toy_document_orgmode_python_en.org +++ b/module2/exo1/toy_document_orgmode_python_en.org @@ -12,7 +12,7 @@ #+HTML_HEAD: * Asking the math library -My computer tells me that \pi is approximatively +My computer tells me that $\pi$ is /approximatively/ #+begin_src python :results value :session *python* :exports both from math import * pi @@ -21,8 +21,9 @@ pi #+RESULTS: : 3.141592653589793 -* Buffon's needle - Applying the method of [[https://en.wikipedia.org/wiki/Buffon%27s_needle_problem][Buffon's]] needle, we get the approximation +* Buffon's needle +Applying the method of +[[https://en.wikipedia.org/wiki/Buffon%27s_needle_problem][Buffon's needle]], we get the *approximation* #+begin_src python :results value :session *python* :exports both import numpy as np @@ -44,9 +45,7 @@ then $P[X^2+Y^2 \le 1]=\pi/4$ (see method" on Wikipedia]]). The following code uses this approach: - - -#+begin_src python :results output :session *python* :var matplot_lib_filename="figure.png" :exports code +#+begin_src python :results output file :session *python* :var matplot_lib_filename="figure.png" :exports both import matplotlib.pyplot as plt np.random.seed(seed=42) @@ -67,18 +66,21 @@ print(matplot_lib_filename) #+end_src #+RESULTS: -: figure.png +[[file:figure.png]] + + + -[[./figure.png]] It is then straightforward to obtain a (not really good) approximation to \pi by counting how many times, on average, $X^2+Y^2$ is smaller than 1: - -#+begin_src python :results value :session *python* :exports both +#+begin_src python :results output :session *python* :exports both 4*np.mean(accept) #+end_src #+RESULTS: : 3.112 + +