lib/distribution/binomial/ruby.rb in distribution-0.4.0 vs lib/distribution/binomial/ruby.rb in distribution-0.5.0

- old
+ new

@@ -1,11 +1,12 @@ module Distribution module Binomial module Ruby_ class << self def pdf(k,n,pr) - Math.binomial_coefficient(n,k)*(pr**k)*(1-pr)**(n-k) + raise "k>n" if k>n + Math.binomial_coefficient(n,k)*(pr**k)*(1-pr)**(n-k) end def cdf(k,n,pr) #(0..x.floor).inject(0) {|ac,i| ac+pdf(i,n,pr)} Math.regularized_beta_function(1-pr,n - k,k+1) end @@ -22,6 +23,6 @@ alias :exact_pdf :pdf end end end -end \ No newline at end of file +end