Top Level Namespace

Defined Under Namespace

Classes: Factor, Gaussian, LikelihoodFactor, Matrix, PriorFactor, Rating, SumFactor, TrueSkillObject, TruncateFactor, Variable

Constant Summary collapse

MU =
25.0
SIGMA =
MU/3
BETA =
SIGMA/2
TAU =
SIGMA/100
DRAW_PROBABILITY =
0.10
DELTA =
0.001

Instance Method Summary collapse

Instance Method Details

#_team_sizes(rating_groups) ⇒ Object


46
47
48
49
50
51
52
53
# File 'lib/TrueSkill/general.rb', line 46

def _team_sizes(rating_groups)
  team_sizes=[0]
  rating_groups.each do |group|
    team_sizes << group.length+team_sizes.last
  end
  team_sizes.delete_at(0)
  return team_sizes
end

#calc_draw_margin(draw_probability, beta, size) ⇒ Object


42
43
44
# File 'lib/TrueSkill/general.rb', line 42

def calc_draw_margin(draw_probability, beta, size)
  return ppf((draw_probability+1)/2.0)*Math.sqrt(size)*beta
end

#calc_draw_probability(draw_margin, beta, size) ⇒ Object


38
39
40
# File 'lib/TrueSkill/general.rb', line 38

def calc_draw_probability(draw_margin,beta,size)
  return 2*cdf(draw_margin*(Math.sqrt(size)*beta))-1
end

#cdf(x, mu = 0, sigma = 1) ⇒ Object


16
17
18
# File 'lib/TrueSkill/Mathematics/general.rb', line 16

def cdf(x,mu=0,sigma=1)
 return 0.5*Math.erfc(-(x-mu)/(sigma*Math.sqrt(2)))
end

#gObject


56
57
58
59
60
61
# File 'lib/TrueSkill/general.rb', line 56

def g()
  if $global.length==0
    setup()
  end
  return $global[0]
end

#ierfcc(p) ⇒ Object


3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/TrueSkill/Mathematics/general.rb', line 3

def ierfcc(p)
 return -100 if p >= 2.0
 return 100 if p <= 0.0
 pp = p < 1.0 ? p : 2 - p
 t = Math.sqrt(-2*Math.log(pp/2.0)) # Initial guess
 x = -0.70711*((2.30753 + t*0.27061)/(1.0 + t*(0.99229 + t*0.04481)) - t)
 [0,1].each do |j|
   err = Math.erfc(x) - pp
   x += err/(1.12837916709551257*Math.exp(-(x*x)) - x*err) 
 end
 p < 1.0 ? x : -x
end

#pdf(x, mu = 0, sigma = 1) ⇒ Object


19
20
21
# File 'lib/TrueSkill/Mathematics/general.rb', line 19

def pdf(x,mu=0,sigma=1)
 return (1/Math.sqrt(2*Math::PI)*sigma.abs)*Math.exp(-(((x-mu)/sigma.abs)**2/2))
end

#ppf(x, mu = 0, sigma = 1) ⇒ Object


22
23
24
# File 'lib/TrueSkill/Mathematics/general.rb', line 22

def ppf(x,mu=0,sigma=1)
 return mu-sigma*Math.sqrt(2)*ierfcc(2*x)
end

#setup(mu = MU, sigma = SIGMA, beta = BETA, tau = TAU, draw_probability = DRAW_PROBABILITY, env = nil) ⇒ Object


62
63
64
65
66
67
68
69
70
# File 'lib/TrueSkill/general.rb', line 62

def setup(mu=MU, sigma=SIGMA, beta=BETA, tau=TAU,draw_probability=DRAW_PROBABILITY, env=nil)
  $global.pop
  if env.nil?
    $global << TrueSkillObject.new(mu, sigma, beta, tau, draw_probability)
  else
    $global << env
  end
  return g()
end