Class: Gaussian

Inherits:
Object
  • Object
show all
Defined in:
lib/TrueSkill/Mathematics/guassian.rb

Direct Known Subclasses

Rating, Variable

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mu = nil, sigma = nil, pi = 0, tau = 0) ⇒ Gaussian

Returns a new instance of Gaussian.



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

def initialize(mu=nil,sigma=nil,pi=0,tau=0)
  if not mu.nil?
    if sigma.nil? or sigma==0.0
      raise "a variance(sigma^2) should be greater than 0"
    end
    pi=sigma**-2
    tau=pi*mu
  end
  @pi=pi
  @tau=tau
end

Instance Attribute Details

#muObject

Returns the value of attribute mu.



2
3
4
# File 'lib/TrueSkill/Mathematics/guassian.rb', line 2

def mu
  @mu
end

#piObject

Returns the value of attribute pi.



2
3
4
# File 'lib/TrueSkill/Mathematics/guassian.rb', line 2

def pi
  @pi
end

#sigmaObject

Returns the value of attribute sigma.



2
3
4
# File 'lib/TrueSkill/Mathematics/guassian.rb', line 2

def sigma
  @sigma
end

#tauObject

Returns the value of attribute tau.



2
3
4
# File 'lib/TrueSkill/Mathematics/guassian.rb', line 2

def tau
  @tau
end

Instance Method Details

#*(y) ⇒ Object



27
28
29
30
31
# File 'lib/TrueSkill/Mathematics/guassian.rb', line 27

def *(y)
  pi=@pi+y.pi
  tau=@tau+y.tau
  return Gaussian.new(nil,nil,pi,tau)
end

#/(y) ⇒ Object



32
33
34
35
36
# File 'lib/TrueSkill/Mathematics/guassian.rb', line 32

def /(y)
  pi=@pi-y.pi
  tau=@tau-y.tau
  return Gaussian.new(nil,nil,pi,tau)
end