Skip to content

Commit

Permalink
new
Browse files Browse the repository at this point in the history
  • Loading branch information
rlouf committed Jun 6, 2022
1 parent f552739 commit dbb7282
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions aemcmc/conjugates.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
conjugatesdb = OptimizationDatabase()


def beta_binomial_conjugateo(observation_model_expr, value_expr, posterior_expr):
def beta_binomial_conjugateo(observed_rv_expr, posterior_expr):
r"""Produce a goal that represents the application of Bayes theorem
for a beta prior with a binomial observation model.
Expand All @@ -25,6 +25,15 @@ def beta_binomial_conjugateo(observation_model_expr, value_expr, posterior_expr)
p \sim \operatorname{Beta}\left(\alpha + Y, \beta + n - Y\right)
Parameters
----------
observed_rv_expr
A tuple that contains expressions that represent the observed variable
and it observed value respectively.
posterior_exp
An expression that represents the posterior distribution of the latent
variable.
"""

# Beta-binomial observation model
Expand Down Expand Up @@ -55,8 +64,8 @@ def beta_binomial_conjugateo(observation_model_expr, value_expr, posterior_expr)
)

return lall(
eq(observation_model_expr, Y_et),
eq(value_expr, y_lv),
eq(observed_rv_expr[0], Y_et),
eq(observed_rv_expr[1], y_lv),
eq(posterior_expr, p_posterior_et),
)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_conjugates.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_beta_binomial_conjugate_contract():
y_vv.tag.name = "y"

q_lv = var()
(posterior_expr,) = run(1, q_lv, beta_binomial_conjugateo(Y_rv, y_vv, q_lv))
(posterior_expr,) = run(1, q_lv, beta_binomial_conjugateo((Y_rv, y_vv), q_lv))
posterior = eval_if_etuple(posterior_expr)
aesara.dprint(posterior)

Expand Down

0 comments on commit dbb7282

Please sign in to comment.