PyMC can give you the probability of a rounded distribution directly. The equivalent to the first model in Stan is something like this (disclaimer: I didn’t run this code):
import pymc as pm
def rounded_normal_dist(mu, sigma, size):
return pm.math.round(pm.Normal.dist(mu, sigma, size=size))
with pm.Model() as m:
mu = pm.Flat("mu")
sigma = pm.HalfNormal("sigma")
y_obs = pm.CustomDist("y_obs", mu, sigma, dist=rounded_normal_dist, observed=[10, 10, 12, 11, 9])
Docstrings on CustomDist, and the dist
param specifically: pymc.CustomDist — PyMC v5.13.1 documentation