Skip to content

Commit 532d869

Browse files
AlexAndorraricardoV94
authored andcommitted
Added test_multinomial_zero_probs test
1 parent 3cd9cb6 commit 532d869

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Diff for: pymc3/tests/test_distributions.py

+10
Original file line numberDiff line numberDiff line change
@@ -2272,6 +2272,16 @@ def test_batch_multinomial(self):
22722272
sample = dist.eval()
22732273
assert_allclose(sample, np.stack([vals, vals], axis=0))
22742274

2275+
def test_multinomial_zero_probs(self):
2276+
# test multinomial accepts 0 probabilities / observations:
2277+
value = aesara.shared(np.array([0, 0, 100], dtype=int))
2278+
logp = pm.Multinomial.logp(value=value, n=100, p=at.constant([0.0, 0.0, 1.0]))
2279+
logp_fn = aesara.function(inputs=[], outputs=logp)
2280+
assert logp_fn() >= 0
2281+
2282+
value.set_value(np.array([50, 50, 0], dtype=int))
2283+
assert np.isneginf(logp_fn())
2284+
22752285
@pytest.mark.parametrize("n", [2, 3])
22762286
def test_dirichlet_multinomial(self, n):
22772287
self.check_logp(

0 commit comments

Comments
 (0)