当前位置: 首页>>代码示例>>Golang>>正文


Golang DistributionBag.NextIndex方法代码示例

本文整理汇总了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
}
开发者ID:mafredri,项目名称:go-trueskill,代码行数:55,代码来源:skill_factors.go


注:本文中的github.com/mafredri/go-trueskill/collection.DistributionBag.NextIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。