Skip to content

Commit

Permalink
Test for discrete
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhruvanshu-Joshi committed Aug 13, 2023
1 parent 2efaefe commit c9d4697
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions tests/logprob/test_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import pymc as pm

from pymc import logp
from pymc.logprob import conditional_logp
from pymc.logprob.abstract import _logcdf_helper, _logprob_helper
from pymc.testing import assert_no_rvs


Expand Down Expand Up @@ -156,4 +156,16 @@ def test_max_discrete():
x_max_value = pt.scalar("x_max_value")
x_max_logprob = logp(x_max, x_max_value)

x_max_logprob.eval({x_max_value: 0.85})
discrete_logprob = _logprob_helper(x, x_max_value)
discrete_logcdf = _logcdf_helper(x, x_max_value)
discrete_logcdf_prev = _logcdf_helper(x, x_max_value - 1)
n = x.size
discrete_logprob = pt.log((pt.exp(discrete_logcdf)) ** n - (pt.exp(discrete_logcdf_prev)) ** n)

test_value = 0.85

np.testing.assert_allclose(
discrete_logprob.eval({x_max_value: test_value}),
(x_max_logprob.eval({x_max_value: test_value})),
rtol=1e-06,
)

0 comments on commit c9d4697

Please sign in to comment.