module Violence::Helpers
Public Instance Methods
powerlaw(k)
click to toggle source
# File lib/violence/helpers.rb, line 10 def powerlaw(k) (k + 1) * (rand ** k) end
randn()
click to toggle source
# File lib/violence/helpers.rb, line 3 def randn # Normal distributed random, mu = 0 and sigma = 1 # Box-Muller transform u1 = 1-rand u2 = 1-rand Math.sqrt(-2 * Math.log(u1)) * Math.cos(2 * Math::PI * u2) end