Module: Distribution::Poisson::Ruby_
- Defined in:
- lib/distribution/poisson/ruby.rb
Class Method Summary collapse
Class Method Details
.cdf(k, l) ⇒ Object
8 9 10 |
# File 'lib/distribution/poisson/ruby.rb', line 8 def cdf(k,l) Math.exp(-l)*(0..k).inject(0) {|ac,i| ac+ (l**i).quo(Math.factorial(i))} end |
.p_value(prob, l) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/distribution/poisson/ruby.rb', line 11 def p_value(prob,l) ac=0 (0..100).each do |i| ac+=pdf(i,l) return i if prob<=ac end end |