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


Python Gaussian.from_precision_mean方法代码示例

本文整理汇总了Python中skills.numerics.Gaussian.from_precision_mean方法的典型用法代码示例。如果您正苦于以下问题:Python Gaussian.from_precision_mean方法的具体用法?Python Gaussian.from_precision_mean怎么用?Python Gaussian.from_precision_mean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在skills.numerics.Gaussian的用法示例。


在下文中一共展示了Gaussian.from_precision_mean方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: update_message_variable

# 需要导入模块: from skills.numerics import Gaussian [as 别名]
# 或者: from skills.numerics.Gaussian import from_precision_mean [as 别名]
    def update_message_variable(self, message, variable):
        old_marginal = copy(variable.value)
        old_message = copy(message.value)
        message_from_var = old_marginal / old_message

        c = message_from_var.precision
        d = message_from_var.precision_mean

        sqrt_c = sqrt(c)
        d_on_sqrt_c = d / sqrt_c

        epsilon_times_sqrt_c = self.epsilon * sqrt_c
        d = message_from_var.precision_mean

        denom = 1.0 - w_exceeds_margin(d_on_sqrt_c, epsilon_times_sqrt_c)

        new_precision = c / denom
        new_precision_mean = (d + sqrt_c * v_exceeds_margin(d_on_sqrt_c, epsilon_times_sqrt_c)) / denom

        new_marginal = Gaussian.from_precision_mean(new_precision_mean, new_precision)
        new_message = (old_message * new_marginal) / old_marginal

        message.value = new_message
        variable.value = new_marginal

        return new_marginal - old_marginal
开发者ID:agoragames,项目名称:PythonSkills,代码行数:28,代码来源:factors.py

示例2: create_variable_to_message_binding

# 需要导入模块: from skills.numerics import Gaussian [as 别名]
# 或者: from skills.numerics.Gaussian import from_precision_mean [as 别名]
 def create_variable_to_message_binding(self, variable):
     new_distribution = Gaussian.from_precision_mean(0.0, 0.0)
     binding = Factor.create_variable_to_message_binding_with_message(
         self,
         variable,
         Message(new_distribution, "message from {} to {}".format(self, variable))
     )
     return binding
开发者ID:agoragames,项目名称:PythonSkills,代码行数:10,代码来源:factors.py

示例3: partial_update

# 需要导入模块: from skills.numerics import Gaussian [as 别名]
# 或者: from skills.numerics.Gaussian import from_precision_mean [as 别名]
    def partial_update(self, prior, full_posterior, update_percentage):
        prior_gaussian = Gaussian(prior.mean, prior.stdev)
        posterior_gaussian = Gaussian(full_posterior.mean, full_posterior.stdev)

        partial_precision_diff = update_percentage * (posterior_gaussian.precision - prior_gaussian.precision)

        partial_precision_mean_diff = update_percentage * (posterior_gaussian.precision_mean - prior_gaussian.precision_mean)

        partial_posterior_gaussian = Gaussian.from_precision_mean(
            prior_gaussian.precision_mean + partial_precision_mean_diff,
            prior_gaussian.precision + partial_precision_diff)

        return Rating(partial_posterior_gaussian.mean,
                      partial_posterior_gaussian.stdev)
开发者ID:agoragames,项目名称:PythonSkills,代码行数:16,代码来源:__init__.py

示例4: __init__

# 需要导入模块: from skills.numerics import Gaussian [as 别名]
# 或者: from skills.numerics.Gaussian import from_precision_mean [as 别名]
 def __init__(self, teams, team_ranks, game_info):
     game_info = TrueSkillGameInfo.ensure_game_info(game_info)
     FactorGraph.__init__(self)
     self.prior_layer = PlayerPriorValuesToSkillsLayer(self, teams)
     self.game_info = game_info
     new_factory = VariableFactory(lambda: Gaussian.from_precision_mean(0.0, 0.0))
     self.variable_factory = new_factory
     self.layers = [
         self.prior_layer,
         PlayerSkillsToPerformancesLayer(self),
         PlayerPerformancesToTeamPerformancesLayer(self),
         IteratedTeamDifferencesInnerLayer(self,
                                           TeamPerformancesToTeamPerformanceDifferencesLayer(self),
                                           TeamDifferencesComparisonLayer(self, team_ranks))
     ]
开发者ID:McLeopold,项目名称:PythonSkills,代码行数:17,代码来源:__init__.py

示例5: update_helper

# 需要导入模块: from skills.numerics import Gaussian [as 别名]
# 或者: from skills.numerics.Gaussian import from_precision_mean [as 别名]
    def update_helper(self, message1, message2, variable1, variable2):
        message1_value = copy(message1.value)
        message2_value = copy(message2.value)

        marginal1 = copy(variable1.value)
        marginal2 = copy(variable2.value)

        a = self.precision / (self.precision + marginal2.precision - message2_value.precision)

        new_message = Gaussian.from_precision_mean(
            a * (marginal2.precision_mean - message2_value.precision_mean),
            a * (marginal2.precision - message2_value.precision))

        old_marginal_without_message = marginal1 / message1_value

        new_marginal = old_marginal_without_message * new_message

        message1.value = new_message
        variable1.value = new_marginal

        return new_marginal - marginal1
开发者ID:agoragames,项目名称:PythonSkills,代码行数:23,代码来源:factors.py

示例6: __init__

# 需要导入模块: from skills.numerics import Gaussian [as 别名]
# 或者: from skills.numerics.Gaussian import from_precision_mean [as 别名]
 def __init__(self, mean, variance, variable):
     GaussianFactor.__init__(self, "Prior value going to %s" % variable)
     self.new_message = Gaussian(mean, sqrt(variance))
     new_message = Message(Gaussian.from_precision_mean(0, 0),
                           "message from %s to %s" % (self, variable))
     self.create_variable_to_message_binding_with_message(variable, new_message)
开发者ID:agoragames,项目名称:PythonSkills,代码行数:8,代码来源:factors.py


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