Hello! I’m trying to sample from a tempered posterior distribution. As I understand, I should be doing this using pm.Potential, but no matter how I arrange things I can’t get the temperature parameter to have any effect on the sampled distribution.
Here’s the code I’m using to test things:
import numpy as np
import pymc as pm
import pytensor.tensor as pt
import arviz as az
np.random.seed(42)
X = np.random.normal(loc=0, scale=1, size=500)
def tempered_gaussian(
observations,
beta=1.0,
):
with pm.Model() as model:
## Priors
mu = pm.Normal("mu", mu=0, sigma=10)
sigma = pm.HalfNormal("sigma", sigma=10)
likelihood = pm.Normal("likelihood", mu=mu, sigma=sigma, observed=observations)
tempered_ll = pm.Potential("tempered_ll", beta*likelihood)
return model
model = tempered_gaussian(X, beta=1/np.log(X.size))
with model:
idata = pm.sample(
draws=10000,
tune=1000,
chains=4,
)
az.plot_trace(idata.posterior)
No matter what I set beta to, it doesn’t change the output distribution. Even e.g. beta=0 doesn’t seem to do anything. What am I doing wrong?
Thanks in advance.