This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function compute_pi(N::Int) | |
""" | |
Compute pi with a Monte Carlo simulation of N darts thrown in [-1,1]^2 | |
Returns estimate of pi | |
""" | |
n_landed_in_circle = 0 # counts number of points that have radial coordinate < 1, i.e. in circle | |
for i = 1:N | |
x = rand() * 2 - 1 # uniformly distributed number on x-axis | |
y = rand() * 2 - 1 # uniformly distributed number on y-axis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat /proc/cpuinfo | grep processor | wc -l |