Update toy_document_fr.Rmd 5

parent 30e542da
...@@ -24,7 +24,7 @@ Mais calculé avec la **méthode** des [aiguilles de Buffon] (https://fr.wikiped ...@@ -24,7 +24,7 @@ Mais calculé avec la **méthode** des [aiguilles de Buffon] (https://fr.wikiped
```{r} ```{r}
set.seed(42) set.seed(42)
N = 100000 N = 100000
x = ruinif(N) x = runif(N)
theta = pi/2*runif(N) theta = pi/2*runif(N)
2/(mean(x+sin(theta)>1)) 2/(mean(x+sin(theta)>1))
``` ```
...@@ -38,7 +38,7 @@ df$Accept = (df$X**2 + df$Y**2 <=1) ...@@ -38,7 +38,7 @@ df$Accept = (df$X**2 + df$Y**2 <=1)
library(ggplot2) library(ggplot2)
ggplot(df, aes(x=X,y=Y,color=Accept)) + geom_point(alpha=.2) + coord_fixed() + theme_bw() 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, nne, $X^2 + Y^2$ est inférieur à 1 : Il est alors aisé d'obtenir une approximation (pas terrible) de $\pi$ en comptant combien de fois, en moyennne, $X^2 + Y^2$ est inférieur à 1 :
```{r} ```{r}
4*mean(df$Accept) 4*mean(df$Accept)
``` ```
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment