I used two sets of codes to estimate the value of pi as a simple example of Monte Carlo methods.

Code 1:

```
function compute_pi(N::Int)
n_landed_in_circle = 0
for i = 1:N
x = rand()
y = rand()
r2 = x*x + y*y
if r2 < 1.0
n_landed_in_circle += 1
end
end
return n_landed_in_circle / N * 4.0
end
```

Code2:

```
function compute_pi1(N::Int)
return 4 * sum([1 for _ in filter(_ -> rand()^2 + rand()^2 < 1, 1:N)]) / N
end
```

I tested the speed with N = 1_000_000_000, and found that code1 is 2 times faster than code 2. I am not sure what makes the difference.

I used Julia 6.2 on Fedora 25 OS with I7 core and 16gb ram.