lib/distribution/exponential/ruby.rb in distribution-0.7.3 vs lib/distribution/exponential/ruby.rb in distribution-0.8.0

- old
+ new

@@ -2,22 +2,27 @@ module Exponential module Ruby_ class << self def rng(l, opts = {}) rng = opts[:random] || Random - lambda {p_value(rng.rand,l)} + -> { p_value(rng.rand, l) } end - def pdf(x,l) - return 0 if x<0 - l*Math.exp(-l*x) + + def pdf(x, l) + return 0 if x < 0 + l * Math.exp(-l * x) end - def cdf(x,l) - return 0 if x<0 - 1-Math.exp(-l*x) + + def cdf(x, l) + return 0 if x < 0 + 1 - Math.exp(-l * x) end - def p_value(pr,l) - (-Math.log(1-pr)).quo(l) + + def quantile(pr, l) + (-Math.log(1 - pr)).quo(l) end + + alias_method :p_value, :quantile end end end end