Module: Distribution::Exponential::Ruby_

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

Class Method Summary collapse

Class Method Details

.cdf(x, l) ⇒ Object



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

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

.pdf(x, l) ⇒ Object



10
11
12
13
# File 'lib/distribution/exponential/ruby.rb', line 10

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

.quantile(pr, l) ⇒ Object Also known as: p_value



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

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

.rng(l, opts = {}) ⇒ Object



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

def rng(l, opts = {})
  rng = opts[:random] || Random
  -> { p_value(rng.rand, l) }
end