Class: Distem::Events::SimpleRandomGenerator
- Inherits:
-
RandomGenerator
- Object
- RandomGenerator
- Distem::Events::SimpleRandomGenerator
- Defined in:
- lib/distem/events/simplerandomgenerator.rb
Instance Method Summary (collapse)
- - (Object) advance_state(displacement)
-
- (SimpleRandomGenerator) initialize(seed = nil)
constructor
Class which badly generates random numbers All the instances of this class use the same random generator, embedded in the Kernel module This should not be used.
- - (Object) rand_U01
Constructor Details
- (SimpleRandomGenerator) initialize(seed = nil)
Class which badly generates random numbers All the instances of this class use the same random generator, embedded in the Kernel module This should not be used.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/distem/events/simplerandomgenerator.rb', line 10 def initialize(seed = nil) if seed # Set the seed for everyone uses this class (!) if seed.is_a?(Array) tmp_seed = 0 seed.each do |x| tmp_seed += x end seed = tmp_seed end srand(seed) end end |
Instance Method Details
- (Object) advance_state(displacement)
26 27 28 |
# File 'lib/distem/events/simplerandomgenerator.rb', line 26 def advance_state(displacement) # Not supported, so, does nothing... end |
- (Object) rand_U01
22 23 24 |
# File 'lib/distem/events/simplerandomgenerator.rb', line 22 def rand_U01 return rand end |