Sha256: 9b26161e7009260063c4cf0111bd71b3131a20cec232163c8706a896cc77da48
Contents?: true
Size: 465 Bytes
Versions: 6
Compression:
Stored size: 465 Bytes
Contents
class RailsDataExplorer module Statistics class RngPowerLaw def initialize(min = 1, max = 1000, pow = 2, rng = lambda { Kernel.rand }) @min, @max, @pow, @rng = min, max, pow, rng @max += 1 end def rand y = ( ( (@max ** (@pow + 1) - @min ** (@pow + 1)) * @rng.call + @min ** (@pow + 1) ) ** (1.0 / (@pow + 1)) ).to_i (@max - 1 - y) + @min end end end end
Version data entries
6 entries across 6 versions & 1 rubygems