The Gaussian class
The Gaussian class does most of the computation of the packages.
TrueSkillThroughTime.Gaussian — TypeThe Gaussian class is used to define the prior beliefs of the agents' skills (and for internal computations).
We can create objects by passing the parameters in order or by mentioning the names.
Gaussian(mu::Float64=MU, sigma::Float64=SIGMA)
Gaussian(;mu::Float64=MU, sigma::Float64=SIGMA)- muis the mean of the Gaussian distribution
- sigmais the standar deviation of the Gaussian distribution
The default value of MU and SIGMA are
N06 = ttt.Gaussian()Gaussian(mu=0.0, sigma=6.0)Others ways to create Gaussian objects
N01 = ttt.Gaussian(sigma = 1.0)
N12 = ttt.Gaussian(1.0, 2.0)
Ninf = ttt.Gaussian(1.0,Inf)
println("mu: ", N01.mu, ", sigma: ", N01.sigma)mu: 0.0, sigma: 1.0The class overwrites the addition +, subtraction -, product *, and division / to compute the marginal distributions used in the TrueSkill Through Time model.
Product *
- $k \mathcal{N}(x|\mu,\sigma^2) = \mathcal{N}(x|k\mu,(k\sigma)^2)$
- $\mathcal{N}(x|\mu_1,\sigma_1^2)\mathcal{N}(x|\mu_2,\sigma_2^2) \propto \mathcal{N}(x|\mu_{*},\sigma_{*}^2)$
with $\frac{\mu_{*}}{\sigma_{*}^2} = \frac{\mu_1}{\sigma_1^2} + \frac{\mu_2}{\sigma_2^2}$ and $\sigma_{*}^2 = (\frac{1}{\sigma_1^2} + \frac{1}{\sigma_2^2})^{-1}$.
Base.:* — Function*(N::Gaussian, M::Gaussian)+(k::Float64, M::Gaussian)julia> N06 * N12Gaussian(mu=0.9, sigma=1.897367)julia> N12 * 5.0Gaussian(mu=5.0, sigma=10.0)julia> N12 * NinfGaussian(mu=1.0, sigma=2.0)
Division /
- $\mathcal{N}(x|\mu_1,\sigma_1^2)/\mathcal{N}(x|\mu_2,\sigma_2^2) \propto \mathcal{N}(x|\mu_{\div},\sigma_{\div}^2)$
with $\frac{\mu_{\div}}{\sigma_{\div}^2} = \frac{\mu_1}{\sigma_1^2} - \frac{\mu_2}{\sigma_2^2}$ and $\sigma_{\div}^2 = (\frac{1}{\sigma_1^2} - \frac{1}{\sigma_2^2})^{-1}$.
Base.:/ — Function/(N::Gaussian, M::Gaussian)julia> N12 / N06Gaussian(mu=1.125, sigma=2.12132)julia> N12 / NinfGaussian(mu=1.0, sigma=2.0)
Addition +
- $\iint \delta(t=x + y) \mathcal{N}(x|\mu_1, \sigma_1^2)\mathcal{N}(y|\mu_2, \sigma_2^2) dxdy = \mathcal{N}(t|\mu_1+\mu_2,\sigma_1^2 + \sigma_2^2)$
Base.:+ — Function+(N::Gaussian, M::Gaussian)julia> N06 + N12Gaussian(mu=1.0, sigma=6.324555)
Substraction -
- $\iint \delta(t=x - y) \mathcal{N}(x|\mu_1, \sigma_1^2)\mathcal{N}(y|\mu_2, \sigma_2^2) dxdy = \mathcal{N}(t|\mu_1-\mu_2,\sigma_1^2 + \sigma_2^2)$
Base.:- — Function-(N::Gaussian, M::Gaussian)julia> N06 - N12Gaussian(mu=-1.0, sigma=6.324555)
Others methods
isapprox
Base.isapprox — Functionisapprox(N::Gaussian, M::Gaussian, atol::Real=0)julia> N06-N12 == ttt.Gaussian(mu=-1.0, sigma=6.324555)falsejulia> ttt.isapprox(N06-N12, ttt.Gaussian(mu=-1.0, sigma=6.324555), 1e-6)true
forget
TrueSkillThroughTime.forget — Functionforget(N::Gaussian, gamma::Float64, t::Int64=1)