From 4307febcc2c19d3525c600e68496abb5aef8bd09 Mon Sep 17 00:00:00 2001 From: Lucie Leonarski Date: Wed, 22 Jul 2020 21:00:55 +0200 Subject: [PATCH] Mon 3eme commit exo2 --- module2/exo1/toy_document_orgmode_python_fr.org | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/module2/exo1/toy_document_orgmode_python_fr.org b/module2/exo1/toy_document_orgmode_python_fr.org index af8b3eb..9244c13 100644 --- a/module2/exo1/toy_document_orgmode_python_fr.org +++ b/module2/exo1/toy_document_orgmode_python_fr.org @@ -36,10 +36,11 @@ theta = np.random.uniform(size=N, low=0, high=pi/2) #+end_src #+RESULTS: +: * Avec un argument "fréquentiel" de surface -Sinon, une méthode plus simple à comprendre et ne faisant pas intervenir d'appel à la fonction sinus se base sur le fait que si $X \sim U(0,1)$ et $Y \sim U(0,1)$ alors $P[X^2+Y^2 ≤1]=\pi/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 : +Sinon, une méthode plus simple à comprendre et ne faisant pas intervenir d'appel à la fonction sinus se base sur le fait que si $X \sim U(0,1)$ et $Y \sim U(0,1)$ alors $P[X^2+Y^2 \leq 1]=\pi/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 file :session :var matplot_lib_filename="./random_uniform_pi.png" :exports results import matplotlib.pyplot as plt @@ -63,10 +64,10 @@ print(matplot_lib_filename) #+end_src #+RESULTS: -[[File:random_uniform_pi.png]] +[[file:random_uniform_pi.png]] -Il est alors aisé d'obtenir une approximation (pas terrible) de π en comptant combien de fois, en moyenne, X^2+Y^2 est inférieur à 1 : +Il est alors aisé d'obtenir une approximation (pas terrible) de $π$ en comptant combien de fois, en moyenne, $X^2+Y^2$ est inférieur à 1 : #+begin_src python :results output :session :exports both 4*np.mean(accept) -- 2.18.1