Class: Variable
- Defined in:
- lib/TrueSkill/FactorGraph/Variable.rb
Instance Attribute Summary
Attributes inherited from Gaussian
Instance Method Summary collapse
- #[](y) ⇒ Object
- #[]=(y, value) ⇒ Object
- #delta(other) ⇒ Object
-
#initialize ⇒ Variable
constructor
A new instance of Variable.
- #set(val) ⇒ Object
- #to_s ⇒ Object
- #update_message(factor, pi = 0, tau = 0, message = nil) ⇒ Object
- #update_value(factor, pi = 0, tau = 0, value = nil) ⇒ Object
Methods inherited from Gaussian
Constructor Details
#initialize ⇒ Variable
Returns a new instance of Variable.
6 7 8 9 |
# File 'lib/TrueSkill/FactorGraph/Variable.rb', line 6 def initialize() super() @messages={} end |
Instance Method Details
#[](y) ⇒ Object
38 39 40 |
# File 'lib/TrueSkill/FactorGraph/Variable.rb', line 38 def [](y) @messages[y] end |
#[]=(y, value) ⇒ Object
42 43 44 |
# File 'lib/TrueSkill/FactorGraph/Variable.rb', line 42 def []=(y,value) @messages[y]=value end |
#delta(other) ⇒ Object
16 17 18 |
# File 'lib/TrueSkill/FactorGraph/Variable.rb', line 16 def delta(other) return [(@tau-other.tau).abs,Math.sqrt((@pi-other.pi).abs)].max end |
#set(val) ⇒ Object
11 12 13 14 15 |
# File 'lib/TrueSkill/FactorGraph/Variable.rb', line 11 def set(val) @delta=delta(val) @pi=val.pi @tau=val.tau end |
#to_s ⇒ Object
45 46 47 |
# File 'lib/TrueSkill/FactorGraph/Variable.rb', line 45 def to_s return "<Variable "+self.object_id.to_s+" mu="+self.mu.to_s+" sigma= "+self.sigma.to_s+">" end |
#update_message(factor, pi = 0, tau = 0, message = nil) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/TrueSkill/FactorGraph/Variable.rb', line 20 def (factor,pi=0,tau=0,=nil) if .nil? =Gaussian.new(nil,nil,pi,tau) end =self[factor] self[factor]= return set(self/*) end |
#update_value(factor, pi = 0, tau = 0, value = nil) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/TrueSkill/FactorGraph/Variable.rb', line 29 def update_value(factor,pi=0,tau=0,value=nil) if value.nil? value=Gaussian.new(nil,nil,pi,tau) end =self[factor] self[factor]=value*/self return set(value) end |