From 6331c514f88e93d517377e0c575e3527ebe52ffe Mon Sep 17 00:00:00 2001 From: 99d292aec7079aad242d36ac4efbad08 <99d292aec7079aad242d36ac4efbad08@app-learninglab.inria.fr> Date: Tue, 7 Apr 2020 16:47:18 +0000 Subject: [PATCH] Add second section about buffon --- module2/exo1/toy_document_orgmode_python_fr.org | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/module2/exo1/toy_document_orgmode_python_fr.org b/module2/exo1/toy_document_orgmode_python_fr.org index 38bffca..e7990af 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 -- 2.18.1