From ab959a32494ac657851733ccc3c5c10e3877b398 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mil=C3=A8na=20CHABERT?= Date: Fri, 4 Aug 2023 17:27:54 +0200 Subject: [PATCH] Premier jet exercice --- module2/exo1/toy_document_fr.Rmd | 7 +-- module2/exo1/toy_document_fr.html | 77 +++++++++++++++++-------------- 2 files changed, 45 insertions(+), 39 deletions(-) diff --git a/module2/exo1/toy_document_fr.Rmd b/module2/exo1/toy_document_fr.Rmd index 7bb4ec5..16448dd 100644 --- a/module2/exo1/toy_document_fr.Rmd +++ b/module2/exo1/toy_document_fr.Rmd @@ -21,7 +21,7 @@ theta = pi/2*runif(N) 2/(mean(x+sin(theta)>1)) ``` # Avec un argument "fréquentil" de surface -Sinon, une méthode plus simple à comprendre et ne faisant pas intervenir d'appel à la fonction sinus se base sur le faire que si +Sinon, une méthode plus simple à comprendre et ne faisant pas intervenir d'appel à la fonction sinus se base sur le faire que si $X U(0,1)$ et $Y U(0,1)$ alors $P[X^2+Y^2<= 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: ```{r Monte Carlo} set.seed(42) @@ -31,10 +31,7 @@ df$Accept = (df$X**2 + df$Y**2 <=1) library(ggplot2) ggplot(df, aes(x=X,y=Y,color=Accept)) + geom_point(alpha=.2) + coord_fixed() + theme_bw() ``` -Il est alors aisé d'obtenir une approximation (pas terrible) de $\pi$ en comptant combien de fois, en moyenne, -```{r} - -``` +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: ````{r Comptage} 4*mean(df$Accept) diff --git a/module2/exo1/toy_document_fr.html b/module2/exo1/toy_document_fr.html index d8a09c4..1f87746 100644 --- a/module2/exo1/toy_document_fr.html +++ b/module2/exo1/toy_document_fr.html @@ -9,10 +9,10 @@ - + -Votre titre +À propos du calcul de pi