Sha256: 60d4497887b85e52d3b3dc7e6af0dcef01c24a9b27b63863e16a605e2c777968

Contents?: true

Size: 398 Bytes

Versions: 3

Compression:

Stored size: 398 Bytes

Contents

module Distribution
  module Exponential
    module Ruby_
      class << self
        def rng(l)
	  lambda {p_value(rand(),l)}
	end
	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)
        end
        def p_value(pr,l)
          (-Math.log(1-pr)).quo(l)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
distribution-0.7.0 lib/distribution/exponential/ruby.rb
distribution-0.6.0 lib/distribution/exponential/ruby.rb
distribution-0.5.0 lib/distribution/exponential/ruby.rb