diff --git a/module2/exo1/toy_document_en.Rmd b/module2/exo1/toy_document_en.Rmd index dd0b405d9716e6546c5a8dc72dcdea868e71213c..9e7dda048eaa813e6dddef9677065723026c63ab 100644 --- a/module2/exo1/toy_document_en.Rmd +++ b/module2/exo1/toy_document_en.Rmd @@ -31,9 +31,10 @@ theta = pi/2*runif(N) ## Using a surface fraction argument -A method that is easier to understand and does not make use of the $\sin$ function is based on the fact that if $X $\sim$ U(0,1)$ and $Y $\sim$ U (0,1)$, then $P[X^2 + Y^2 $\le$ 1] = $\pi$/4$ (see ["Monte Carlo method" on Wikipedia](https://en.wikipedia.org/wiki/Monte_Carlo_method)). The following code uses this approach: +A method that is easier to understand and does not make use of the $\sin$ function is based on the fact that if $X \sim U(0,1)$ and $Y \sim U(0,1)$, then $P[X^2 + Y^2 \le 1] = \pi/4$ (see ["Monte Carlo method" on Wikipedia](https://en.wikipedia.org/wiki/Monte_Carlo_method)). The following code uses this approach: -```set.seed(42) +```{r} +set.seed(42) N = 1000 df = data.frame(X = runif(N), Y = runif(N)) df$Accept = (df$X**2 + df$Y**2 <=1)