diff --git a/module2/exo1/toy_document_orgmode_python_en.html b/module2/exo1/toy_document_orgmode_python_en.html index cff6770f9c63289a97db6cd76e29baf2f0c47dec..013d0eb9e851e8e16bb0f0127260e1526b370091 100644 --- a/module2/exo1/toy_document_orgmode_python_en.html +++ b/module2/exo1/toy_document_orgmode_python_en.html @@ -4,7 +4,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- +-My computer tells me that π is approximatively +My computer tells me that \(\pi\) is approximatively
Applying the method of Buffon’s needle, we get the approximation @@ -295,11 +295,11 @@ np.random.seed(seed=42)
-A method that is easier to understand and does not make use of the sin function is based on the fact that if \(X \approx U(0,1)\) and \(Y \approx U(0,1)\), then \(P[X^2 + Y^2 \leq 1] = \pi/4\) (see “Monte Carlo method on Wikipedia”). The following code uses this approach:
+A method that is easier to understand and does not make use of the sin function is based on the fact that if \(X \sim U(0,1)\) and \(Y \sim U(0,1)\), then \(P[X^2 + Y^2 \leq 1] = \pi/4\) (see “Monte Carlo method” on Wikipedia). The following code uses this approach:
import matplotlib.pyplot as plt @@ -330,7 +330,7 @@ plt.savefig(matplot_lib_filename)-It is then straightforward to obtain a (not really good) approximation to π by counting how many times, on average, \(X^2 + Y^2\) is smaller than 1: +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:
4*np.mean(accept) @@ -345,7 +345,7 @@ It is then straightforward to obtain a (not really good) approximation to π b-diff --git a/module2/exo1/toy_document_orgmode_python_en.org b/module2/exo1/toy_document_orgmode_python_en.org index 6b259245c43dd8cddefe6dbdd6705a464bf5a36f..c01b752cade3b45575bc1cf3db04ec3cfedbb550 100644 --- a/module2/exo1/toy_document_orgmode_python_en.org +++ b/module2/exo1/toy_document_orgmode_python_en.org @@ -2,7 +2,7 @@ #+LANGUAGE: en # #+PROPERTY: header-args :session :exports both * 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 * @@ -27,7 +27,7 @@ theta = np.random.uniform(size=N, low=0, high=pi/2) : 3.128911138923655 * Using a surface fraction argument -A method that is easier to understand and does not make use of the =sin= function is based on the fact that if $X \approx U(0,1)$ and $Y \approx U(0,1)$, then $P[X^2 + Y^2 \leq 1] = \pi/4$ (see [[https://en.wikipedia.org/wiki/Monte_Carlo_method]["Monte Carlo method on Wikipedia"]]). The following code uses this approach: +A method that is easier to understand and does not make use of the =sin= function is based on the fact that if $X \sim U(0,1)$ and $Y \sim U(0,1)$, then $P[X^2 + Y^2 \leq 1] = \pi/4$ (see [[https://en.wikipedia.org/wiki/Monte_Carlo_method]["Monte Carlo method" on Wikipedia]]). The following code uses this approach: #+begin_src python :results output file :var matplot_lib_filename="figure_pi_mc2.png" :exports both :session *python* import matplotlib.pyplot as plt @@ -52,7 +52,7 @@ print(matplot_lib_filename) [[file:figure_pi_mc2.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: +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 output :session *python* :exports both 4*np.mean(accept) #+end_srcCreated: 2020-04-28 mar. 11:54
+Created: 2020-04-28 mar. 12:01