Class: Capricious::Uniform
- Inherits:
-
Object
- Object
- Capricious::Uniform
- Includes:
- PRNG
- Defined in:
- lib/capricious/uniform.rb
Overview
Creates pseudorandom numbers in the range [0,1) that satisfy a uniform distribution.
Direct Known Subclasses
Constant Summary collapse
- UNIFORM_MIN =
0.0
- UNIFORM_MAX =
1.0
Instance Method Summary collapse
-
#expected_mean ⇒ Object
Returns the expected mean for this distribution: =(min + max) / 2=.
-
#expected_variance ⇒ Object
Returns the expected variance for this distribution: =(max - min) ** 2 / 12=.
Methods included from PRNG
included, #initialize, #next, #prng_initialize, #reset
Instance Method Details
#expected_mean ⇒ Object
Returns the expected mean for this distribution: =(min + max) / 2=.
30 31 32 |
# File 'lib/capricious/uniform.rb', line 30 def expected_mean (min + max) / 2 end |
#expected_variance ⇒ Object
Returns the expected variance for this distribution: =(max - min) ** 2 / 12=.
35 36 37 |
# File 'lib/capricious/uniform.rb', line 35 def expected_variance ((max - min) ** 2) / 12 end |