class PlanOut::OpRandom
Constants
- LONG_SCALE
Public Instance Methods
get_hash(appended_unit = nil)
click to toggle source
# File lib/plan_out/op_random.rb, line 14 def get_hash(appended_unit = nil) salt = @parameters[:salt] salty = "#{@mapper.experiment_salt}.#{salt}" unit_str = get_unit(appended_unit).join('.') x = "#{salty}.#{unit_str}" last_hex = (Digest::SHA1.hexdigest(x))[0..14] last_hex.to_i(16) end
get_uniform(min_val = 0.0, max_val = 1.0, appended_unit = nil)
click to toggle source
# File lib/plan_out/op_random.rb, line 23 def get_uniform(min_val = 0.0, max_val = 1.0, appended_unit = nil) zero_to_one = self.get_hash(appended_unit)/LONG_SCALE min_val + (max_val-min_val) * zero_to_one end
get_unit(appended_unit = nil)
click to toggle source
# File lib/plan_out/op_random.rb, line 7 def get_unit(appended_unit = nil) unit = @parameters[:unit] unit = [unit] if !unit.is_a? Array unit += appended_unit if appended_unit != nil unit end