Module: Distribution::Exponential::Ruby_
- Defined in:
- lib/distribution/exponential/ruby.rb
Class Method Summary collapse
Class Method Details
.cdf(x, l) ⇒ Object
13 14 15 16 |
# File 'lib/distribution/exponential/ruby.rb', line 13 def cdf(x,l) return 0 if x<0 1-Math.exp(-l*x) end |
.p_value(pr, l) ⇒ Object
17 18 19 |
# File 'lib/distribution/exponential/ruby.rb', line 17 def p_value(pr,l) (-Math.log(1-pr)).quo(l) end |
.pdf(x, l) ⇒ Object
9 10 11 12 |
# File 'lib/distribution/exponential/ruby.rb', line 9 def pdf(x,l) return 0 if x<0 l*Math.exp(-l*x) 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 lambda {p_value(rng.rand,l)} end |