From 3611675bde7b6a1c75c32b23c10ba9a28b51dab5 Mon Sep 17 00:00:00 2001 From: dc230e4232c633941d7b74c8cce89395 Date: Mon, 23 Aug 2021 13:16:48 +0000 Subject: [PATCH] Commit after corrections --- module2/exo1/toy_document_en.Rmd | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/module2/exo1/toy_document_en.Rmd b/module2/exo1/toy_document_en.Rmd index dd0b405..9e7dda0 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) -- 2.18.1