Module: Distribution::Normal

Defined in:
lib/distribution/normal.rb

Overview

Calculate cdf and inverse cdf for Normal Distribution. Uses Statistics2 module

Class Method Summary collapse

Class Method Details

.cdf(x) ⇒ Object

Normal cumulative distribution function (cdf).

Returns the integral of normal distribution over (-Infty, x].



15
16
17
# File 'lib/distribution/normal.rb', line 15

def cdf(x)
    Statistics2.normaldist(x)
end

.p_value(pr) ⇒ Object

Return the P-value of the corresponding integral



7
8
9
# File 'lib/distribution/normal.rb', line 7

def p_value(pr)
    Statistics2.pnormaldist(pr)
end

.pdf(x) ⇒ Object

Normal probability density function (pdf) With x=0 and sigma=1



20
21
22
# File 'lib/distribution/normal.rb', line 20

def pdf(x)
    (1.0/Math::sqrt(2*Math::PI))*Math::exp(-(x**2/2.0))
end