diff --git a/module2/exo1/toy_document_orgmode_python_fr.org b/module2/exo1/toy_document_orgmode_python_fr.org index a82e8799b3c473db428c6977511d7d8da66a2c98..a48fd14234dbb4c3202eef420390a0ced8f65c52 100644 --- a/module2/exo1/toy_document_orgmode_python_fr.org +++ b/module2/exo1/toy_document_orgmode_python_fr.org @@ -15,20 +15,21 @@ Mon ordinateur indique que \pi vaut /approximativement/: -#+begin_src python :results output :exports both +#+begin_src python :results output :session :exports both from math import * pi #+end_src #+RESULTS: -: 3.141592653589793 +: Python 3.7.7 (tags/v3.7.7:d7c567b08f, Mar 10 2020, 10:41:24) [MSC v.1900 64 bit (AMD64)] on win32 +: Type "help", "copyright", "credits" or "license" for more information. * 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 +#+begin_src python :results output :session :exports both import numpy as np np.random.seed(seed=42) N = 10000 @@ -38,7 +39,6 @@ theta = np.random.uniform(size=N, low=0, high=pi/2) #+end_src #+RESULTS: -: 3.128911138923655 * Avec un argument "fréquentiel" de surface @@ -48,7 +48,7 @@ X∼U(0,1) et Y∼U(0,1) alors P[X^2+Y^2≤1]=π/4 (voir [[https://fr.wikipedia.org/wiki/M%C3%A9thode_de_Monte-Carlo#D%C3%A9termination_de_la_valeur_de_%CF%80][méthode de Monte Carlo sur Wikipedia]]). Le code suivant illustre ce fait : -#+begin_src python :results output :session :exports both +#+begin_src python :results output file :session :var matplot_lib_filename="./figure_pi_mc2.png" :exports both import matplotlib.pyplot as plt np.random.seed(seed=42) @@ -68,6 +68,13 @@ plt.savefig(matplot_lib_filename) print(matplot_lib_filename) #+end_src +#+RESULTS: +[[file:Traceback (most recent call last): + File "", line 1, in + File "c:/Users/bouac/AppData/Local/Temp/babel-3bK4It/python-AEJboM", line 4, in + np.random.seed(seed=42) +NameError: name 'np' is not defined]] + #+begin_src python :results output :session :exports both 4*np.mean(accept) #+end_src