How to use the observed parameter and what's the meaning?

I found that some codes use :

pm.DensityDist(‘likelihood’, lambda v: logl(v), observed={‘v’: theta})
pm.DensityDist(‘likelihood’, my_loglike,
observed={‘theta’: (m, c), ‘x’: x, ‘data’: data, ‘sigma’: sigma})
such as :v

some like: obs = pm.Normal(‘obs’, mu=mu, sd=1, observed=np.random.randn(100))
such as :randn

some like :like = pymc.Normal(‘y_est’, mu=alpha + beta * xdata, sd=sigma, observed=ydata)
such as :ydata(python - Defining the Stochastic and Deterministic variables with pymc3 - Cross Validated)

I was confused.What’s the difference?

In general, the observed keyword is used to define the likelihood terms (as opposed to the priors on the parameter terms), however, with DensityDist if using a dictionary, the observed keyword is used to pass kwargs to the likelihood function, any kwargs, observations, model parameters, constants…

Taking a look at the multiple possibilities to do exactly the same thing with DensityDist from Using a random variable as observed - #5 by OriolAbril might help understand how observed in DensityDist has nothing to do with observed keyword in all other density distributions

2 Likes

Thanks!I will think about it carefully.