diff --git a/module2/exo1/figure.png b/module2/exo1/figure.png new file mode 100644 index 0000000000000000000000000000000000000000..da2eadaf247d0c57730d196cd5e661aa5a53e293 Binary files /dev/null and b/module2/exo1/figure.png differ diff --git a/module2/exo1/toy_document_orgmode_python_fr.org b/module2/exo1/toy_document_orgmode_python_fr.org index c7157ba42216cf2e1d291112bb351ce48811115c..b074cc933819d988aae05f381c9e95cd0c233d41 100644 --- a/module2/exo1/toy_document_orgmode_python_fr.org +++ b/module2/exo1/toy_document_orgmode_python_fr.org @@ -1,15 +1,15 @@ -#+TITLE: Votre titre -#+AUTHOR: Votre nom -#+DATE: La date du jour +#+TITLE: À propos du calcul de π +#+AUTHOR: Paul Beziau +#+DATE: 9/12/2021 #+LANGUAGE: fr # #+PROPERTY: header-args :eval never-export -#+HTML_HEAD: -#+HTML_HEAD: -#+HTML_HEAD: -#+HTML_HEAD: -#+HTML_HEAD: -#+HTML_HEAD: +# #+HTML_HEAD: +# #+HTML_HEAD: +# #+HTML_HEAD: +# #+HTML_HEAD: +# #+HTML_HEAD: +# #+HTML_HEAD: * Quelques explications @@ -91,3 +91,54 @@ faisant ~
1)/N)
+#+end_src
+
+#+RESULTS:
+: 3.128911138923655
+
+* Avec un argument "fréquentiel" de surface
+
+#+begin_src python :results file :session :var matplot_lib_filename="figure.png" :exports both
+
+import matplotlib.pyplot as plt
+
+np.random.seed(seed=42)
+N = 1000
+x = np.random.uniform(size=N, low=0, high=1)
+y = np.random.uniform(size=N, low=0, high=1)
+
+accept = (x*x+y*y) <= 1
+reject = np.logical_not(accept)
+
+fig, ax = plt.subplots(1)
+ax.scatter(x[accept], y[accept], c='b', alpha=0.2, edgecolor=None)
+ax.scatter(x[reject], y[reject], c='r', alpha=0.2, edgecolor=None)
+ax.set_aspect('equal')
+
+plt.savefig(matplot_lib_filename)
+print(matplot_lib_filename)
+ #+end_src
+
+#+RESULTS:
+[[file: