From 92080e7d9013d767e5178ccd84a6e57c7d5ed6e6 Mon Sep 17 00:00:00 2001
From: 40c80c20e9bd61900d2b7a608cb1be68
<40c80c20e9bd61900d2b7a608cb1be68@app-learninglab.inria.fr>
Date: Fri, 17 Mar 2023 23:56:18 +0100
Subject: [PATCH] =?UTF-8?q?ajout=20contenu=20exercice,=20reste=20=C3=A0=20?=
=?UTF-8?q?mettre=20en=20forme=20md?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
module2/exo1/toy_document_fr.Rmd | 40 ++++++--
module2/exo1/toy_document_fr.Rmd~ | 4 +-
module2/exo1/toy_document_fr.html | 153 +++++++++++++++++-------------
3 files changed, 119 insertions(+), 78 deletions(-)
diff --git a/module2/exo1/toy_document_fr.Rmd b/module2/exo1/toy_document_fr.Rmd
index c15b496..4643d3e 100644
--- a/module2/exo1/toy_document_fr.Rmd
+++ b/module2/exo1/toy_document_fr.Rmd
@@ -1,7 +1,7 @@
---
-title: "Votre titre"
-author: "Votre nom"
-date: "La date du jour"
+title: "À propos du calcul de pi"
+author: "Thomas Sévère"
+date: "17/03/2023"
output: html_document
---
@@ -11,16 +11,38 @@ knitr::opts_chunk$set(echo = TRUE)
```
-## Quelques explications
+## En demandant à la lib maths
-```{r cars}
-summary(cars)
+```{r}
+pi
```
+## 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 obtiendrait comme **approximation** :
+
+```{r}
+set.seed(42)
+N = 100000
+x = runif(N)
+theta = pi/2*runif(N)
+2/(mean(x+sin(theta)>1))
+```
+
+## Avec un argument “fréquentiel” de surface
-Et on peut aussi aisément inclure des figures. Par exemple:
+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∼U(0,1) et Y∼U(0,1) alors P[X2+Y2≤1]=π/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 pressure, echo=FALSE}
-plot(pressure)
+```{r}
+set.seed(42)
+N = 1000
+df = data.frame(X = runif(N), Y = runif(N))
+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 π en comptant combien de fois, en moyenne, $\X2+Y2$ est inférieur à 1:
+
+```{r}
+4*mean(df$Accept)
+```
diff --git a/module2/exo1/toy_document_fr.Rmd~ b/module2/exo1/toy_document_fr.Rmd~
index 1996da7..c15b496 100644
--- a/module2/exo1/toy_document_fr.Rmd~
+++ b/module2/exo1/toy_document_fr.Rmd~
@@ -8,13 +8,11 @@ output: html_document
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
+
```
## Quelques explications
-Ceci est un document R markdown que vous pouvez aisément exporter au format HTML, PDF, et MS Word. Pour plus de détails sur R Markdown consultez .
-
-Lorsque vous cliquerez sur le bouton **Knit** ce document sera compilé afin de ré-exécuter le code R et d'inclure les résultats dans un document final. Comme nous vous l'avons montré dans la vidéo, on inclue du code R de la façon suivante:
```{r cars}
summary(cars)
diff --git a/module2/exo1/toy_document_fr.html b/module2/exo1/toy_document_fr.html
index fe0c764..4c31d30 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
-
+ h1.title {font-size: 38px;}
+ h2 {font-size: 30px;}
+ h3 {font-size: 24px;}
+ h4 {font-size: 18px;}
+ h5 {font-size: 16px;}
+ h6 {font-size: 12px;}
+ code {color: inherit; background-color: rgba(0, 0, 0, 0.04);}
+ pre:not([class]) { background-color: white }
+ code{white-space: pre-wrap;}
+ span.smallcaps{font-variant: small-caps;}
+ span.underline{text-decoration: underline;}
+ div.column{display: inline-block; vertical-align: top; width: 50%;}
+ div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
+ ul.task-list{list-style: none;}
+