Building a normal likelihood with known but varying variance for every data point/sample

I am trying to build a model where I have a known error for each of my y data point which varies for each sample. What is the right way of incorporating this uncertainty for getting the posterior distribution of unknown parameters? I am thinking including this uncertainty in the likelihood model (e.g. Gaussian) as the std dev (varying for each y sample). How do I code this in pymc3.? I am new to Bayesian inference & some references would be great. Thanks.

1 Like

It should be pretty straightforward. Something like this:

obs_noise = np.array([1.9, 2.7, ..., 1.1])
obs = np.array([5, 6, ..., 1])

with pm.Model() as m:
  < Unobserved variables >
  like = pm.Normal("like", mu = <model prediction>, sigma=obs_noise, observed=obs)