Sha256: a7e14ea819bfcab3c0203dd41a0f02e77ffb8bebf239f277b8722b1f370a1673
Contents?: true
Size: 620 Bytes
Versions: 77
Compression:
Stored size: 620 Bytes
Contents
module SocialStream module Population class PowerLaw # Yields each element of array y times given by # {power law distribution}[http://en.wikipedia.org/wiki/Power_law] # y = ax**k + e # # Options: Each constant in the function # def initialize(array, options = {}) options[:a] ||= array.size options[:k] ||= -2.5 options[:e] ||= 1 array.each do |i| value = options[:a] * (array.index(i) + 1) ** options[:k] + options[:e] value.round.times do yield i end end end end end end
Version data entries
77 entries across 77 versions & 2 rubygems