Class: Reputation::Functions::GeneralisedLogisticCurve

Inherits:
Object
  • Object
show all
Includes:
Mixin
Defined in:
lib/reputation/functions/generalised_logistic_curve.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Mixin

#google_chart, #google_chart_url

Constructor Details

#initialize(args = {}) ⇒ GeneralisedLogisticCurve

Returns a new instance of GeneralisedLogisticCurve.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/reputation/functions/generalised_logistic_curve.rb', line 9

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

Instance Attribute Details

#aObject

Returns the value of attribute a.



7
8
9
# File 'lib/reputation/functions/generalised_logistic_curve.rb', line 7

def a
  @a
end

#bObject

Returns the value of attribute b.



7
8
9
# File 'lib/reputation/functions/generalised_logistic_curve.rb', line 7

def b
  @b
end

#kObject

Returns the value of attribute k.



7
8
9
# File 'lib/reputation/functions/generalised_logistic_curve.rb', line 7

def k
  @k
end

#mObject

Returns the value of attribute m.



7
8
9
# File 'lib/reputation/functions/generalised_logistic_curve.rb', line 7

def m
  @m
end

#qObject

Returns the value of attribute q.



7
8
9
# File 'lib/reputation/functions/generalised_logistic_curve.rb', line 7

def q
  @q
end

#vObject

Returns the value of attribute v.



7
8
9
# File 'lib/reputation/functions/generalised_logistic_curve.rb', line 7

def v
  @v
end

Instance Method Details

#f(t) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/reputation/functions/generalised_logistic_curve.rb', line 26

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