Sha256: 79570fa4155ee426926a26205e77d44809bd05001a3c14f77434579db7bf6566

Contents?: true

Size: 462 Bytes

Versions: 7

Compression:

Stored size: 462 Bytes

Contents

module Distribution
  module Poisson
    module Ruby_
      class << self
        def pdf(k,l )
          (l**k*Math.exp(-l)).quo(Math.factorial(k))
        end
        def cdf(k,l)
          Math.exp(-l)*(0..k).inject(0) {|ac,i| ac+ (l**i).quo(Math.factorial(i))}
        end
        def p_value(prob,l)
          ac=0
          (0..100).each do |i|
            ac+=pdf(i,l)
            return i if prob<=ac
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
distribution-0.7.3 lib/distribution/poisson/ruby.rb
distribution-0.7.2 lib/distribution/poisson/ruby.rb
distribution-0.7.1 lib/distribution/poisson/ruby.rb
distribution-0.7.0 lib/distribution/poisson/ruby.rb
distribution-0.6.0 lib/distribution/poisson/ruby.rb
distribution-0.5.0 lib/distribution/poisson/ruby.rb
distribution-0.4.0 lib/distribution/poisson/ruby.rb