Module: RaaP::Type::Arithmetic

Defined in:
lib/raap/type.rb

Class Method Summary collapse

Class Method Details

.floatObject



10
11
12
# File 'lib/raap/type.rb', line 10

def self.float
  positive_float.then { |x| [x, -x].sample or raise }
end

.positive_floatObject



14
15
16
17
# File 'lib/raap/type.rb', line 14

def self.positive_float
  x = Random.rand
  x / Math.sqrt(1 - (x * x))
end