# Problem model definition PyMC3

**URL:** <https://discourse.pymc.io/t/problem-model-definition-pymc3/355>\
**Category:** Questions\
**Created:** [September 20, 2017, 1:45pm UTC](https://discourse.pymc.io/t/problem-model-definition-pymc3/355 "2017-09-20T13:45:01Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![junpenglao](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/junpenglao/32/8_2.png) [@junpenglao](https://discourse.pymc.io/u/junpenglao)\
**Post date:** [September 21, 2017, 7:30am UTC](https://discourse.pymc.io/t/problem-model-definition-pymc3/355/6 "2017-09-21T07:30:30Z")

</div>

In `pm.DensityDist`, `observed` are the parameters _and_ data you pass to the custom log-likelihood function.

If you want to make it more clear, you can also rewrite the logp function like this:

```auto
# Log likelihood function
def logp_function(parameters):
    def logp(observed):
        some_scaler = some_function(parameters, observed)
        return some_scaler

    return logp # returns a function

```

In your case, it would be:

```auto
def likelihoodMCMC(m, q, sigmay):
    def logp(value):
        return tt.exp(0.5*tt.sum(
            tt.log(1/(2*np.pi*(sigmay**2 + value[3]**2 + (m*value[2])**2))) -
            (value[1] - m*value[0] - q)**2/(sigmay**2 + value[3]**2 + (m*value[2])**2)))
    return logp

```

where `value = (logEiso, logEpeak_i, logErrEiso, logErrEpeak_i)`

Then you can call it as:

```auto
with pm.Model() as model:
    ...
    obs_peaks = pm.DensityDist('obs_peak', likelihoodMCMC(m,q,sigmay), 
               observed=(logEiso, logEpeak_i, logErrEiso, logErrEpeak_i))

```

---

_[View the full topic](https://discourse.pymc.io/t/problem-model-definition-pymc3/355)._
