diff --git a/module2/exo1/toy_document_orgmode_python_fr.org b/module2/exo1/toy_document_orgmode_python_fr.org index 38bffca65acc575113572bc50674552976e88abf..e7990af2980e81b666da25a13eb8b80a0344d4b4 100644 --- a/module2/exo1/toy_document_orgmode_python_fr.org +++ b/module2/exo1/toy_document_orgmode_python_fr.org @@ -8,7 +8,7 @@ #+HTML_HEAD: #+HTML_HEAD: -# #+PROPERTY: header-args :eval never-export +#+PROPERTY: header-args :session :exports both * En demandant à la lib maths Mon ordinateur m'indique que $\pi$ vaut /approximativement/: @@ -23,8 +23,21 @@ pi * En utilisant la méthode des aiguilles de Buffon +Mais calculé avec la *méthode* des [[https://fr.wikipedia.org/wiki/Aiguille_de_Buffon][aiguilles de Buffon]], on obtiendrait comme *approximation* : +#+begin_src python :results output :exports both +import numpy as np +np.random.seed(seed=42) +N = 10000 +x = np.random.uniform(size=N, low=0, high=1) +theta = np.random.uniform(size=N, low=0, high=pi/2) +2/(sum((x+np.sin(theta))>1)/N) +#+end_src + +#+RESULTS: +: 3.12891113892 +---- Ceci est un document org-mode avec quelques exemples de code python. Une fois ouvert dans emacs, ce document peut aisément être exporté au format HTML, PDF, et Office. Pour plus de détails sur