Module: Distribution::Exponential::Ruby_

Defined in:
lib/distribution/exponential/ruby.rb

Class Method Summary collapse

Class Method Details

.cdf(x, l) ⇒ Object



12
13
14
15
# File 'lib/distribution/exponential/ruby.rb', line 12

def cdf(x,l)
  return 0 if x<0
  1-Math.exp(-l*x)
end

.p_value(pr, l) ⇒ Object



16
17
18
# File 'lib/distribution/exponential/ruby.rb', line 16

def p_value(pr,l)
  (-Math.log(1-pr)).quo(l)
end

.pdf(x, l) ⇒ Object



8
9
10
11
# File 'lib/distribution/exponential/ruby.rb', line 8

def pdf(x,l)
  return 0 if x<0
  l*Math.exp(-l*x)
end

.rng(l) ⇒ Object



5
6
7
# File 'lib/distribution/exponential/ruby.rb', line 5

def rng(l)
  lambda {p_value(rand(),l)}
end