From 1270045601ed772457d11538d4e35cf471711456 Mon Sep 17 00:00:00 2001 From: Jade Bolaty Date: Sat, 2 Nov 2024 16:23:54 +0100 Subject: [PATCH] =?UTF-8?q?correction=20de=20quelques=20=C3=A9l=C3=A9ments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module2/exo1/toy_document_orgmode_R_fr.org | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/module2/exo1/toy_document_orgmode_R_fr.org b/module2/exo1/toy_document_orgmode_R_fr.org index e495dcd..b7e59e0 100644 --- a/module2/exo1/toy_document_orgmode_R_fr.org +++ b/module2/exo1/toy_document_orgmode_R_fr.org @@ -1,4 +1,4 @@ -#+TITLE: À propos du calcul de \pi +#+TITLE: À propos du calcul de $\pi$ #+AUTHOR: Arnaud Legrand #+DATE: <2024-11-02 sam.> #+LANGUAGE: fr @@ -19,7 +19,7 @@ * <>1 En demandant à la lib maths -Mon ordinateur m'indique que \pi vaut /approximativement/ +Mon ordinateur m'indique que $\pi$ vaut /approximativement/ #+begin_src R :results output :session *R* :exports both pi @@ -47,10 +47,10 @@ theta = pi/2*runif(N) * <>3 Avec un argument "fréquentiel" de surface Sinon, une méthode plus simple à comprendre et ne faisant pas -intervenir d'appel à lz fonction sinus se base sur le fait que si */X ~ -U(0,1)/* et */Y ~ U(0,1)/* alors */P[X² + Y² <= 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 +intervenir d'appel à lz fonction sinus se base sur le fait que si $X \sim +U(0,1)$ et $Y \sim U(0,1)$ alors $P[X² + Y² <= 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 R :results file graphics :file (org-babel-temp-file "figure" ".png") :exports both :width 600 :height 400 :session *R* +#+begin_src R :results file graphics :file figure_pi_mc1.png :exports both :width 600 :height 400 :session *R* set.seed(42) N = 1000 df = data.frame(X = runif(N), Y = runif(N)) @@ -61,8 +61,8 @@ ggplot(df, aes(x=X,y=Y,color=Accept)) + geom_point(alpha=.2) + coord_fixed() + t #+RESULTS: [[file:c:/Users/Jade/AppData/Local/Temp/babel-B2M9M4/figuredgJtpV.png]] -Il est alors aisé d'obtenir une approximation (pas terrible) de \pi en -comptant combien de fois, en moyenne, */X² + Y²/* est inférieur à 1 : +Il est alors aisé d'obtenir une approximation (pas terrible) de $\pi$ en +comptant combien de fois, en moyenne, $X^2 + Y^2$ est inférieur à 1 : #+begin_src R :results output :session *R* :exports both 4*mean(df$Accept) -- 2.18.1