本文整理汇总了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
}