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


Python numerics.Gaussian类代码示例

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


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


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