Class: TruncateFactor

Inherits:
Factor
  • Object
show all
Defined in:
lib/TrueSkill/FactorGraph/TruncateFactor.rb

Instance Attribute Summary

Attributes inherited from Factor

#vars

Instance Method Summary collapse

Methods inherited from Factor

#var

Constructor Details

#initialize(var, v_func, w_func, draw_margin) ⇒ TruncateFactor

Returns a new instance of TruncateFactor


6
7
8
9
10
11
# File 'lib/TrueSkill/FactorGraph/TruncateFactor.rb', line 6

def initialize(var,v_func,w_func,draw_margin)
  super([var])
  @v_func=v_func
  @w_func=w_func
  @draw_margin=draw_margin
end

Instance Method Details

#to_sObject


28
29
30
# File 'lib/TrueSkill/FactorGraph/TruncateFactor.rb', line 28

def to_s
  return "<TruncateFactor "+self.object_id.to_s+">"
end

#upObject


14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/TrueSkill/FactorGraph/TruncateFactor.rb', line 14

def up()
  val=var
  msg=var[self]
  div=val/msg
  sqrt_pi=Math.sqrt(div.pi)
  
  v=@v_func.call(div.tau/sqrt_pi,@draw_margin*sqrt_pi)
  w=@w_func.call(div.tau/sqrt_pi,@draw_margin*sqrt_pi)
  
  denom=(1.0-w)
  pi=div.pi/denom
  tau=(div.tau+sqrt_pi*v)/denom
  return var.update_value(self,pi,tau)
end