Module: GA::Random
- Defined in:
- lib/rugal.rb
Constant Summary collapse
Class Method Summary collapse
- .rand(*args) ⇒ Object
- .rand_int(*args) ⇒ Object
- .random ⇒ Object
- .random_sign ⇒ Object
- .set_seed(i) ⇒ Object
- .shuffle(array) ⇒ Object
- .with_probability(probability) ⇒ Object
Class Method Details
.rand(*args) ⇒ Object
23 24 25 |
# File 'lib/rugal.rb', line 23 def self.rand(*args) @@random.rand *args end |
.rand_int(*args) ⇒ Object
27 28 29 |
# File 'lib/rugal.rb', line 27 def self.rand_int(*args) self.rand(*args).to_i end |
.random ⇒ Object
13 14 15 |
# File 'lib/rugal.rb', line 13 def self.random @@random end |
.random_sign ⇒ Object
37 38 39 40 41 |
# File 'lib/rugal.rb', line 37 def self.random_sign value = self.rand(2) return value == 0 ? -1 : 1 end |
.set_seed(i) ⇒ Object
9 10 11 |
# File 'lib/rugal.rb', line 9 def self.set_seed(i) @@random = Math::Random.new i end |