Class: Capricious::Poisson

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

Overview

Models a Poisson distribution

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) ⇒ Poisson

Initializes a new distribution. =l= is the lambda parameter (which is also the expected mean and variance); =seed=, =policy=, and =keep_stats= are as in =PRNG=. Note that the linear-feedback shift register policy will not provide acceptable results with this and other non-uniform distributions due to extremely high lag-k autocorrelation for small k.



33
34
35
36
37
# File 'lib/capricious/poisson.rb', line 33

def initialize(l, seed=nil, policy=MWC5, keep_stats=false)
  @z = Math.exp(-l)
  @expected_mean = l
  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/poisson.rb', line 26

def expected_mean
  @expected_mean
end

#zObject (readonly)

Returns the value of attribute z.



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

def z
  @z
end

Instance Method Details

#expected_varianceObject



39
40
41
# File 'lib/capricious/poisson.rb', line 39

def expected_variance
  @expected_mean
end