Class: SocialStream::Population::PowerLaw
- Inherits:
-
Object
- Object
- SocialStream::Population::PowerLaw
- Defined in:
- lib/social_stream/population/power_law.rb
Instance Method Summary collapse
-
#initialize(array, options = {}) ⇒ PowerLaw
constructor
Yields each element of array y times given by power law distribution y = ax**k + e.
Constructor Details
#initialize(array, options = {}) ⇒ PowerLaw
Yields each element of array y times given by power law distribution y = ax**k + e
Options: Each constant in the function
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/social_stream/population/power_law.rb', line 10 def initialize(array, = {}) [:a] ||= array.size [:k] ||= -2.5 [:e] ||= 1 array.each do |i| value = [:a] * (array.index(i) + 1) ** [:k] + [:e] value.round.times do yield i end end end |