Skip to content

Instantly share code, notes, and snippets.

Avatar

Cory Simon CorySimon

View GitHub Profile
View compute_pi.jl
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
@CorySimon
CorySimon / gist:c166f96945f42bf57b6b
Last active Aug 29, 2015
Count processors on CPU in Linux
View gist:c166f96945f42bf57b6b
cat /proc/cpuinfo | grep processor | wc -l
You can’t perform that action at this time.