Class: Capricious::Uniform

Inherits:
Object
  • Object
show all
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

BiasedUniform

Constant Summary collapse

UNIFORM_MIN =
0.0
UNIFORM_MAX =
1.0

Instance Method Summary collapse

Methods included from PRNG

included, #initialize, #next, #prng_initialize, #reset

Instance Method Details

#expected_meanObject

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_varianceObject

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