Probability of a certain value in a discrete distribution

You can use .dist to get a distribution from random variable. Using the logp method, you can get the logarithm of the probability and applying np.exp transform will give you probability of that event which is between 0 and 1. Here’s an example:

>>> import pymc3 as pm
>>> import numpy as np
>>> dist = pm.Geometric.dist(p=0.02685)
>>> np.exp(dist.logp(34).eval())
0.010936472378101412
>>> dist_bounded = pm.Bound(pm.Geometric, upper=100).dist(p=0.02685)
>>> np.exp(dist_bounded.logp(34).eval())
0.010936472378101412

If you like, you can refer to this notebook.

2 Likes