Esempio n. 1
0
	team2 := teams[1]
	team2Count := team2.PlayerCount()

	totalPlayers := team1Count + team2Count

	betaSqr := numerics.Sqr(gi.Beta)

	team1MeanSum := team1.Accum(skills.MeanSum)
	team1VarSum := team1.Accum(skills.VarianceSum)

	team2MeanSum := team2.Accum(skills.MeanSum)
	team2VarSum := team2.Accum(skills.VarianceSum)

	// This comes from equation 4.1 in the TrueSkill paper on page 8
	// The equation was broken up into the part under the square root sign and
	// the exponential part to make the code easier to read.

	betaSqrPlayers := betaSqr * float64(totalPlayers)

	sqrtPart := math.Sqrt(betaSqrPlayers / (betaSqrPlayers + team1VarSum + team2VarSum))
	expPart := math.Exp(-.5 * numerics.Sqr(team1MeanSum-team2MeanSum) / (betaSqrPlayers + team1VarSum + team2VarSum))

	return expPart * sqrtPart
}

var (
	twoTeamTeamRange   = numerics.Exactly(2)
	twoTeamPlayerRange = numerics.AtLeast(1)
)
Esempio n. 2
0
	validatePlayersPerTeam(teams, twoPlayerPlayerRange)

	team1 := teams[0]
	p1 := team1.Players()[0]
	p1Rating := team1.PlayerRating(p1)

	team2 := teams[1]
	p2 := team2.Players()[0]
	p2Rating := team2.PlayerRating(p2)

	// We just use equation 4.1 found on page 8 of the TrueSkill 2006 paper:
	betaSqr := numerics.Sqr(gi.Beta)
	p1var := p1Rating.Variance()
	p2var := p2Rating.Variance()

	// This is the square root part of the equation:
	sqrtPart := math.Sqrt(2 * betaSqr / (2*betaSqr + p1var + p2var))

	// This is the exponent part of the equation:
	numerator := -numerics.Sqr(p1Rating.Mean() - p2Rating.Mean())
	denominator := 2 * (2*betaSqr + p1var + p2var)
	expPart := math.Exp(numerator / denominator)

	return sqrtPart * expPart
}

var (
	twoPlayerTeamRange   = numerics.Exactly(2)
	twoPlayerPlayerRange = numerics.Exactly(1)
)