From 4f05b2937954833e9f083d15c129901598e03056 Mon Sep 17 00:00:00 2001 From: e6c214ad3c6f6b7a6b30f79adc457c63 Date: Fri, 9 Jun 2023 14:31:09 +0000 Subject: [PATCH] =?UTF-8?q?3=C3=A8me=20essai=20toy=5Fdocument=5Ffr.Rmd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module2/exo1/toy_document_fr.Rmd | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/module2/exo1/toy_document_fr.Rmd b/module2/exo1/toy_document_fr.Rmd index f3ef3e5..8bca556 100644 --- a/module2/exo1/toy_document_fr.Rmd +++ b/module2/exo1/toy_document_fr.Rmd @@ -1,16 +1,15 @@ --- title: "À propos du calcul de pi" -author: "*Arnaud Legrand*" -date: "*25 juin 2018*" +author: "Arnaud Legrand" +date: "25 juin 2018" output: html_document --- - ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) ``` -# En demandant à la lib maths +## En demandant à la lib maths Mon ordinateur m'indique que $\pi$ vaut *approximativement* @@ -19,7 +18,7 @@ pi ``` -# En utilisant la méthode des aiguilles de Buffon +## En utilisant la méthode des aiguilles de Buffon Mais calculé avec la **méthode** des [aiguilles de Buffon](https://fr.wikipedia.org/wiki/Aiguille_de_Buffon), on @@ -33,11 +32,11 @@ theta = pi/2*runif(N) 2/(mean(x+sin(theta)>1)) ``` -# Avec un argument "fréquentiel" de surface +## 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\leq 1]=\pi$/4$ (voir [méthode de Monte Carlo sur Wikipedia](https://fr.wikipedia.org/wiki/M%C3%A9thode_de_Monte-Carlo#D%C3%A9termination_de_la_valeur_de_%CF%80)). +$P[X^2+Y^2\leq 1] = \pi/4$ (voir [méthode de Monte Carlo sur Wikipedia](https://fr.wikipedia.org/wiki/M%C3%A9thode_de_Monte-Carlo#D%C3%A9termination_de_la_valeur_de_%CF%80)). Le code suivant illustre ce fait: ``` @@ -50,19 +49,10 @@ ggplot(df, aes(x=X,y=Y,color=Accept)) + geom_point(alpha=.2) + coord_fixed() + t ``` 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 : +combien de fois, en moyenne, $X^2 + Y^2$ est inférieur à 1 : ``` 4*mean(df$Accept) ``` - - - - - - - - - -- 2.18.1