Update2 toy_document_fr.Rmd

parent 2a4b3a7e
...@@ -18,14 +18,10 @@ pi ...@@ -18,14 +18,10 @@ pi
Mais calculé avec la **méthode** des [aiguilles de Buffon](https://fr.wikipedia.org/wiki/Aiguille_de_Buffon), on obtiendrait comme **approximation** : Mais calculé avec la **méthode** des [aiguilles de Buffon](https://fr.wikipedia.org/wiki/Aiguille_de_Buffon), on obtiendrait comme **approximation** :
```{r} ```{r}
set.seed(42) set.seed(42)
N = 100000
N = 100000 x = runif(N)
theta = pi/2*runif(N)
x = runif(N)
theta = pi/2*runif(N)
2/(mean(x+sin(theta)>1)) 2/(mean(x+sin(theta)>1))
``` ```
...@@ -38,16 +34,11 @@ $P[X^{2} + Y^{2} \leq 1]= \pi /4$ ...@@ -38,16 +34,11 @@ $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: (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 } ```{r }
set.seed(42) set.seed(42)
N = 1000
N = 1000 df = data.frame(X = runif(N), Y = runif(N))
df$Accept = (df$X**2 + df$Y**2 <=1)
df = data.frame(X = runif(N), Y = runif(N)) library(ggplot2)
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() ggplot(df, aes(x=X,y=Y,color=Accept)) + geom_point(alpha=.2) + coord_fixed() + theme_bw()
``` ```
......
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