Skip to content

Instantly share code, notes, and snippets.

@ieda
ieda / normdist.rb
Created February 23, 2014 13:24 — forked from gareth/normdist.rb
# 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