Class: Capricious::Poisson
- Inherits:
-
Object
- Object
- Capricious::Poisson
- Includes:
- PRNG
- Defined in:
- lib/capricious/poisson.rb
Overview
Models a Poisson distribution
Instance Attribute Summary collapse
-
#expected_mean ⇒ Object
readonly
Returns the value of attribute expected_mean.
-
#z ⇒ Object
readonly
Returns the value of attribute z.
Instance Method Summary collapse
- #expected_variance ⇒ Object
-
#initialize(l, seed = nil, policy = MWC5, keep_stats = false) ⇒ Poisson
constructor
Initializes a new distribution.
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_mean ⇒ Object (readonly)
Returns the value of attribute expected_mean.
26 27 28 |
# File 'lib/capricious/poisson.rb', line 26 def expected_mean @expected_mean end |
#z ⇒ Object (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_variance ⇒ Object
39 40 41 |
# File 'lib/capricious/poisson.rb', line 39 def expected_variance @expected_mean end |