Sha256: eb3161bf606416fe9fe394e9da4620383d13fac22dd8775fbab4c375cd73295b

Contents?: true

Size: 926 Bytes

Versions: 4

Compression:

Stored size: 926 Bytes

Contents

class Reputation
  class Functions
    class GeneralisedLogisticCurve
      
      include Mixin
      
      attr_accessor :a, :k, :b, :v, :q, :m
      
      def initialize(args = {})
        constants = { 
          :a => -1,  # lower asymptote
          :k => 1,   # upper asymptote
          :b => 10,  # growth rate
          :v => 0.5, # affects near which asymptote maximum growth occurs
          :q => 0.5, # depends on the value Y(0)
          :m => 0, # the time of maximum growth if Q=v
        }.merge( args )
        @a = constants[:a]
        @k = constants[:k]
        @b = constants[:b]
        @v = constants[:v]
        @q = constants[:q]
        @m = constants[:m]
      end
      
      def f(t)
        limit( 
          a.to_f + (
            (k.to_f - a.to_f) /
            (1 + q.to_f * Math.exp(-1 * b.to_f*(t.to_f-m.to_f)) )**(1.to_f/v.to_f)
          )
        )
      end
      
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
reputation-0.0.5 lib/reputation/functions/generalised_logistic_curve.rb
reputation-0.0.4 lib/reputation/functions/generalised_logistic_curve.rb
reputation-0.0.3 lib/reputation/functions/generalised_logistic_curve.rb
reputation-0.0.2 lib/reputation/functions/generalised_logistic_curve.rb