Sha256: 0230a2382fbd2aec21819ef9fceb6135aed4f617c4624fb6be725c0f19b051c7

Contents?: true

Size: 472 Bytes

Versions: 3

Compression:

Stored size: 472 Bytes

Contents

module Distribution
  module Exponential
    module Ruby_
      class << self
        def rng(l, opts = {})
          rng = opts[:random] || Random
          lambda {p_value(rng.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.3 lib/distribution/exponential/ruby.rb
distribution-0.7.2 lib/distribution/exponential/ruby.rb
distribution-0.7.1 lib/distribution/exponential/ruby.rb