• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python numerics.Gaussian类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: log_normalization

    def log_normalization(self):
        marginal = self.variables[0].value
        message = self.messages[0].value
        message_from_variable = marginal / message

        return (-Gaussian.log_product_normalization(message_from_variable, message) +
                log(Gaussian.cumulative_to((message_from_variable.mean - self.epsilon) / message_from_variable.stdev)))
开发者ID:agoragames,项目名称:PythonSkills,代码行数:7,代码来源:factors.py


示例2: testLogProductNormalization

    def testLogProductNormalization(self):
        standard_normal = Gaussian(0, 1)
        lpn = Gaussian.log_product_normalization(standard_normal, standard_normal)
        answer = -1.2655121234846454
        self.assertAlmostEqual(answer, lpn, None,
                               "testLogProductNormalization lpn expected %.15f, got %.15f" % (answer, lpn),
                               GaussianDistributionTest.ERROR_TOLERANCE)

        m1s2 = Gaussian(1.0, 2.0)
        m3s4 = Gaussian(3.0, 4.0)
        lpn2 = Gaussian.log_product_normalization(m1s2, m3s4)
        answer = -2.5168046699816684
        self.assertAlmostEqual(answer, lpn2, None,
                               "testLogProductNormalization lpn2 expected %.15f, got %.15f" % (answer, lpn2),
                               GaussianDistributionTest.ERROR_TOLERANCE)
开发者ID:agoragames,项目名称:PythonSkills,代码行数:15,代码来源:test_numerics.py


示例3: update_message_variable

    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,代码行数:26,代码来源:factors.py


示例4: w_within_margin

def w_within_margin(team_performance_difference, draw_margin):
    team_performance_difference_abs = abs(team_performance_difference)
    denominator = (Gaussian.cumulative_to(draw_margin - team_performance_difference_abs) -
                   Gaussian.cumulative_to(-draw_margin - team_performance_difference_abs))

    if denominator < 2.222758749e-162:
        return 1.0

    vt = v_within_margin(team_performance_difference_abs, draw_margin)

    return (vt ** 2 +
            (
                (draw_margin - team_performance_difference_abs) *
                Gaussian.at(draw_margin - team_performance_difference_abs) -
                (-draw_margin - team_performance_difference_abs) *
                Gaussian.at(-draw_margin - team_performance_difference_abs)) / denominator)
开发者ID:Geoff1938,项目名称:PythonSkills,代码行数:16,代码来源:truncated.py


示例5: w_exceeds_margin

def w_exceeds_margin(team_performance_difference, draw_margin):
    denominator = Gaussian.cumulative_to(team_performance_difference - draw_margin)
    if denominator < 2.222758749e-162:
        if team_performance_difference < 0.0:
            return 1.0
        return 0.0
    v_win = v_exceeds_margin(team_performance_difference, draw_margin)
    return v_win * (v_win + team_performance_difference - draw_margin)
开发者ID:Geoff1938,项目名称:PythonSkills,代码行数:8,代码来源:truncated.py


示例6: create_variable_to_message_binding

 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,代码行数:8,代码来源:factors.py


示例7: v_within_margin

def v_within_margin(team_performance_difference, draw_margin):
    team_performance_difference_abs = abs(team_performance_difference)
    denominator = (
        Gaussian.cumulative_to(draw_margin - team_performance_difference_abs) -
        Gaussian.cumulative_to(-draw_margin - team_performance_difference_abs))

    if denominator < 2.222758749e-162:
        if team_performance_difference < 0.0:
            return -team_performance_difference - draw_margin
        return -team_performance_difference + draw_margin

    numerator = (Gaussian.at(-draw_margin - team_performance_difference_abs) -
                 Gaussian.at(draw_margin - team_performance_difference_abs))

    if team_performance_difference < 0.0:
        return -numerator / denominator
    return numerator / denominator
开发者ID:Geoff1938,项目名称:PythonSkills,代码行数:17,代码来源:truncated.py


示例8: testLogRatioNormalization

 def testLogRatioNormalization(self):
     m1s2 = Gaussian(1.0, 2.0)
     m3s4 = Gaussian(3.0, 4.0)
     lrn = Gaussian.log_ratio_normalization(m1s2, m3s4)
     answer = 2.6157405972171204
     self.assertAlmostEqual(answer, lrn, None,
                            "testLogRatioNormalization lrn expected %.15f, got %.15f" % (answer, lrn),
                            GaussianDistributionTest.ERROR_TOLERANCE)
开发者ID:agoragames,项目名称:PythonSkills,代码行数:8,代码来源:test_numerics.py


示例9: partial_update

    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,代码行数:14,代码来源:__init__.py


示例10: __init__

 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,代码行数:15,代码来源:__init__.py


示例11: update_helper

    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,代码行数:21,代码来源:factors.py


示例12: send_message_variable

 def send_message_variable(self, message, variable):
     marginal = variable.value
     message_value = message.value
     log_z = Gaussian.log_product_normalization(marginal, message_value)
     variable.value = marginal * message_value
     return log_z
开发者ID:agoragames,项目名称:PythonSkills,代码行数:6,代码来源:factors.py


示例13: __init__

 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,代码行数:6,代码来源:factors.py


示例14: v_exceeds_margin

def v_exceeds_margin(team_performance_difference, draw_margin):
    denominator = Gaussian.cumulative_to(team_performance_difference - draw_margin)
    if (denominator < 2.22275874e-162):
        return -team_performance_difference + draw_margin
    return Gaussian.at(team_performance_difference - draw_margin) / denominator
开发者ID:Geoff1938,项目名称:PythonSkills,代码行数:5,代码来源:truncated.py


示例15: testAt

 def testAt(self):
     expected = 0.352065326764300
     answer = Gaussian.at(0.5)
     self.assertAlmostEqual(expected, answer, None,
                            "testAt expected %.15f, got %.15f" % (expected, answer),
                            GaussianDistributionTest.ERROR_TOLERANCE)
开发者ID:agoragames,项目名称:PythonSkills,代码行数:6,代码来源:test_numerics.py


示例16: testCumulativeTo

 def testCumulativeTo(self):
     expected = 0.691462461274013
     answer = Gaussian.cumulative_to(0.5)
     self.assertAlmostEqual(expected, answer, None,
                            "testCumulativeTo expected %.15f, got %.15f" % (expected, answer),
                            GaussianDistributionTest.ERROR_TOLERANCE)
开发者ID:agoragames,项目名称:PythonSkills,代码行数:6,代码来源:test_numerics.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python skimage.img_as_float函数代码示例发布时间:2022-05-27
下一篇:
Python skillmodels.SkillModel类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap