Commit after corrections

parent 73a5ff1c
...@@ -31,9 +31,10 @@ theta = pi/2*runif(N) ...@@ -31,9 +31,10 @@ theta = pi/2*runif(N)
## Using a surface fraction argument ## 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 N = 1000
df = data.frame(X = runif(N), Y = runif(N)) df = data.frame(X = runif(N), Y = runif(N))
df$Accept = (df$X**2 + df$Y**2 <=1) df$Accept = (df$X**2 + df$Y**2 <=1)
......
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