Skip to content

Instantly share code, notes, and snippets.

View caicai89's full-sized avatar

Sophia Green caicai89

View GitHub Profile
@gareth
gareth / normdist.rb
Created November 9, 2011 00:43
Ruby Normdist
# Code adapted from http://bytes.com/topic/c-sharp/answers/240995-normal-distribution#post980230
module Normdist
def self.normdist x, mean, std, cumulative
if cumulative
phi_around x, mean, std
else
tmp = 1/((Math.sqrt(2*Math::PI)*std))
tmp * Math.exp(-0.5 * ((x-mean)/std ** 2))
end
end