Skip to content

Commit

Permalink
run precommit
Browse files Browse the repository at this point in the history
  • Loading branch information
wd60622 committed Nov 7, 2023
1 parent c8925a4 commit b9f52b6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
17 changes: 9 additions & 8 deletions pymc_experimental/distributions/discrete.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,19 +171,20 @@ def logp(value, mu, lam):
(-mu / 4) <= lam,
msg="0 < mu, max(-1, -mu/4)) <= lam <= 1",
)



class BetaNegativeBinomial:
R"""
Beta Negative Binomial distribution.
The pmf of this distribution is
.. math::
f(x \mid \alpha, \beta, r) = \frac{B(r + x, \alpha + \beta)}{B(r, \alpha)} \frac{\Gamma(x + \beta)}{x! \Gamma(\beta)}
where :math:`B` is the Beta function and :math:`\Gamma` is the Gamma function.
.. plot::
:context: close-figs
Expand Down Expand Up @@ -216,7 +217,7 @@ def logp(x, alpha, beta, r):
plt.ylabel('f(x)', fontsize=12)
plt.legend(loc=1)
plt.show()
For more information, see https://en.wikipedia.org/wiki/Beta_negative_binomial_distribution.
======== ======================================
Expand Down Expand Up @@ -273,9 +274,9 @@ def __new__(cls, name, alpha, beta, r, **kwargs):
dist=cls.beta_negative_binomial_dist,
logp=cls.beta_negative_binomial_logp,
class_name="BetaNegativeBinomial",
**kwargs
**kwargs,
)

@classmethod
def dist(cls, alpha, beta, r, **kwargs):
return pm.CustomDist.dist(
Expand All @@ -285,10 +286,10 @@ def dist(cls, alpha, beta, r, **kwargs):
dist=cls.beta_negative_binomial_dist,
logp=cls.beta_negative_binomial_logp,
class_name="BetaNegativeBinomial",
**kwargs
**kwargs,
)


class Skellam:
R"""
Skellam distribution.
Expand Down
12 changes: 8 additions & 4 deletions pymc_experimental/tests/distributions/test_discrete.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@
)
from pytensor import config

from pymc_experimental.distributions import BetaNegativeBinomial, GeneralizedPoisson, Skellam
from pymc_experimental.distributions import (
BetaNegativeBinomial,
GeneralizedPoisson,
Skellam,
)


class TestGeneralizedPoisson:
Expand Down Expand Up @@ -121,7 +125,7 @@ def test_moment(self, mu, lam, size, expected):
GeneralizedPoisson("x", mu=mu, lam=lam, size=size)
assert_moment_is_expected(model, expected)


class TestBetaNegativeBinomial:
"""
Wrapper class so that tests of experimental additions can be dropped into
Expand Down Expand Up @@ -189,8 +193,8 @@ def test_logp(self):
np.testing.assert_allclose(
logp_fn(test_value, test_alpha, test_beta, test_r), expected_logp
)


class TestSkellam:
def test_logp(self):
check_logp(
Expand Down

0 comments on commit b9f52b6

Please sign in to comment.