Module: ML::Util
- Defined in:
- lib/util/util.rb
Class Method Summary collapse
Class Method Details
.normal_distribution(mean, variance) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/util/util.rb', line 5 def normal_distribution mean, variance if @y y = @y @y = nil return y end theta = 2 * Math::PI * rand rho = Math.sqrt(-2 * Math.log(1 - rand)) scale = variance * rho x = mean + scale * Math.cos(theta) @y = mean + scale * Math.sin(theta) x end |