Hi,
I am new to PYMC and MCMC sampling in general. I am looking to create a bivariate uniform prior using the CustomDist function - this seems like it should be simple but I’m not exactly sure what I’m doing wrong or how to go about it. I would like the mean of the bivariate normal likelihood to have a uniform prior distribution on the two dimensions. My code is below
#Bounds of Uniform prior
lower_x = 1018478.02
upper_x = 2226794.57
lower_y = 4750305.11
upper_y = 6205666.13
#defining custom multivariate uniform variable
def logp(mu: np.ndarray | float) -> TensorVariable:
p = 1/((upper_x - lower_x)*(upper_y - lower_y))
return pt.as_tensor_variable(np.log(p))
#MCMC sampling with PYMC
basic_model = pm.Model()
with basic_model:
#Uniform Prior
mu = pm.CustomDist("prior",logp=logp)
cov = np.identity(2)
#likelihood
like = pm.MvNormal("like", mu=mu,cov=cov, observed=data.to_numpy())
idata = pm.sample()