Skip to content

Instantly share code, notes, and snippets.

View CorySimon's full-sized avatar

Cory Simon CorySimon

View GitHub Profile
@CorySimon
CorySimon / compute_pi.jl
Last active August 29, 2015 14:13
Compute pi
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 August 29, 2015 14:12
Count processors on CPU in Linux
cat /proc/cpuinfo | grep processor | wc -l