Class: Capricious::Exponential

Inherits:
Object
  • Object
show all
Includes:
PRNG
Defined in:
lib/capricious/exponential.rb

Overview

Exponential-distribution PRNG

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from PRNG

included, #next, #prng_initialize, #reset

Constructor Details

#initialize(l, seed = nil, policy = MWC5, keep_stats = false) ⇒ Exponential

Initializes a new distribution. =l= is the lambda parameter; =seed=,

policy=, and =keep_stats= are as in =PRNG=.



30
31
32
33
34
# File 'lib/capricious/exponential.rb', line 30

def initialize(l, seed=nil, policy=MWC5, keep_stats=false)
  @expected_mean = 1 / l.to_f
  @expected_variance = 1 / (l * l).to_f 
  prng_initialize(seed, policy, keep_stats)
end

Instance Attribute Details

#expected_meanObject (readonly)

Returns the value of attribute expected_mean.



26
27
28
# File 'lib/capricious/exponential.rb', line 26

def expected_mean
  @expected_mean
end

#expected_varianceObject (readonly)

Returns the value of attribute expected_variance.



26
27
28
# File 'lib/capricious/exponential.rb', line 26

def expected_variance
  @expected_variance
end