Update toy_document_fr.Rmd

parent 22bca32b
......@@ -24,3 +24,16 @@ x = runif(N)
theta = pi/2*runif(N)
2/(mean(x+sin(theta)>1))
```
# 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∼U(0,1)
et Y∼U(0,1)
alors P[X2+Y2≤1]=π/4
(voir méthode de Monte Carlo sur Wikipedia). Le code suivant illustre ce fait:
```{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()
```
\ 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