本文整理匯總了Golang中github.com/mafredri/go-trueskill/collection.DistributionBag.NextIndex方法的典型用法代碼示例。如果您正苦於以下問題:Golang DistributionBag.NextIndex方法的具體用法?Golang DistributionBag.NextIndex怎麽用?Golang DistributionBag.NextIndex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/mafredri/go-trueskill/collection.DistributionBag
的用法示例。
在下文中一共展示了DistributionBag.NextIndex方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: buildSkillFactors
func buildSkillFactors(ts Config, players Players, draws []bool, varBag *collection.DistributionBag) (skillFactors, []int, factor.List) {
sf := skillFactors{}
gf := factor.NewGaussianFactors()
factorList := factor.NewList()
numPlayers := players.Len()
skillIndex := []int{}
for i := 0; i < numPlayers; i++ {
skillIndex = append(skillIndex, varBag.NextIndex())
}
for i := 0; i < numPlayers; i++ {
priorSkill := players[i]
gpf := gf.GaussianPrior(priorSkill.Mean(), priorSkill.Variance()+(ts.Tau*ts.Tau), skillIndex[i], varBag)
sf.skillPriorFactors = append(sf.skillPriorFactors, gpf)
factorList.Add(gpf)
}
for i := 0; i < numPlayers; i++ {
sf.playerPerformances = append(sf.playerPerformances, varBag.NextIndex())
}
for i := 0; i < numPlayers; i++ {
glf := gf.GaussianLikeliehood(ts.Beta*ts.Beta, sf.playerPerformances[i], skillIndex[i], varBag, varBag)
sf.skillToPerformanceFactors = append(sf.skillToPerformanceFactors, glf)
factorList.Add(glf)
}
for i := 0; i < numPlayers-1; i++ {
sf.playerPerformanceDifferences = append(sf.playerPerformanceDifferences, varBag.NextIndex())
}
for i := 0; i < numPlayers-1; i++ {
gws := gf.GaussianWeightedSum(1.0, -1.0, sf.playerPerformanceDifferences[i], sf.playerPerformances[i],
sf.playerPerformances[i+1], varBag, varBag, varBag)
sf.performanceToPerformanceDifferencFactors = append(sf.performanceToPerformanceDifferencFactors, gws)
factorList.Add(gws)
}
// TODO: Calculate e (epsilon) separately for each
epsilon := drawMargin(ts.Beta, ts.DrawProb)
for i, draw := range draws {
var f factor.Factor
if draw {
f = gf.GaussianWithin(epsilon, sf.playerPerformanceDifferences[i], varBag)
} else {
f = gf.GaussianGreaterThan(epsilon, sf.playerPerformanceDifferences[i], varBag)
}
sf.greatherThanOrWithinFactors = append(sf.greatherThanOrWithinFactors, f)
factorList.Add(f)
}
return sf, skillIndex, factorList
}