Module: Distribution::Normal::GSL_

Defined in:
lib/distribution/normal/gsl.rb

Class Method Summary collapse

Class Method Details

.cdf(x) ⇒ Object

:nodoc:



11
12
13
# File 'lib/distribution/normal/gsl.rb', line 11

def cdf(x) # :nodoc:
  GSL::Cdf.ugaussian_P(x)
end

.pdf(x) ⇒ Object

:nodoc:



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

def pdf(x) # :nodoc:
  GSL::Ran.gaussian_pdf(x)
end

.quantile(qn) ⇒ Object Also known as: p_value



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

def quantile(qn)
  GSL::Cdf.ugaussian_Pinv(qn)
end

.rng(mean = 0, sigma = 1, seed = nil) ⇒ Object



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

def rng(mean = 0, sigma = 1, seed = nil)
  seed ||= rand(10e8)
  rng = GSL::Rng.alloc(GSL::Rng::MT19937, seed)
  -> { mean + rng.gaussian(sigma) }
end