Method: Faker::Number.normal
- Defined in:
- lib/faker/default/number.rb
.normal(mean: 1, standard_deviation: 1) ⇒ Float
Produces a float given a mean and standard deviation.
147 148 149 150 151 152 |
# File 'lib/faker/default/number.rb', line 147 def normal(mean: 1, standard_deviation: 1) theta = 2 * Math::PI * rand rho = Math.sqrt(-2 * Math.log(1 - rand)) scale = standard_deviation * rho mean + scale * Math.cos(theta) end |