Class: Vangrail::Session::Track

Inherits:
Object
  • Object
show all
Defined in:
lib/vangrail/session.rb

Overview

One rank's running total. Attack and contamination each have one; they decay and accumulate on their own clock and they do not add.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(log_odds) ⇒ Track

Returns a new instance of Track.



61
62
63
64
65
# File 'lib/vangrail/session.rb', line 61

def initialize(log_odds)
  @log_odds = log_odds
  @cusum = 0.0
  @turns = []
end

Instance Attribute Details

#cusumObject

Returns the value of attribute cusum.



58
59
60
# File 'lib/vangrail/session.rb', line 58

def cusum
  @cusum
end

#log_oddsObject

Returns the value of attribute log_odds.



58
59
60
# File 'lib/vangrail/session.rb', line 58

def log_odds
  @log_odds
end

#turnsObject (readonly)

Returns the value of attribute turns.



59
60
61
# File 'lib/vangrail/session.rb', line 59

def turns
  @turns
end

Instance Method Details

#bits(prior) ⇒ Object



71
72
73
# File 'lib/vangrail/session.rb', line 71

def bits(prior)
  log_odds - Math.log2(Posterior.to_odds(prior))
end

#posteriorObject



67
68
69
# File 'lib/vangrail/session.rb', line 67

def posterior
  Posterior.from_odds(2**log_odds)
end