# Margianal likelihood of Gaussian process by using DensityDist

Dear all,

I want to know Margianal likelihood of Gaussian process by using DensityDist

I know there is already gaussian process module in pymc3 but this is practice for my use of pymc3

I made the code like this

``````def MarginalLikelihood(ls, eta, sigma, x, y):
log_p1 = -1/2* y*cov*tt.transpose(y)
log_p2 = tt.nlinalg.Det(cov)#-1/2*tt.log(tt.nlinalg.Det(cov))
log_p3 = -y.size/2*np.log(2*np.pi)
return log_p1+log_p2+log_p3

with pm.Model() as model:
ls = pm.Normal('ls', mu=0, sd=10,  shape=1)
eta = pm.Normal('eta', mu=0, sd=10, shape=1)
sigma = 1e-8
#     pm.HalfNormal('sigma', sd=10)

like = pm.DensityDist('ML', MarginalLikelihood, observed=dict(ls=ls,eta=eta,sigma=sigma,
x=X,
y=y))

trace = pm.sample(2000)
``````

and it gives the error

``````---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-11-bdd19ba5bae4> in <module>()
16     like = pm.DensityDist('ML', MarginalLikelihood, observed=dict(ls=ls,eta=eta,sigma=sigma,
17                                                             x=X,
---> 18                                                             y=y))
19
20     trace = pm.sample(2000)

~/anaconda3/lib/python3.6/site-packages/pymc3/distributions/distribution.py in __new__(cls, name, *args, **kwargs)
35             total_size = kwargs.pop('total_size', None)
36             dist = cls.dist(*args, **kwargs)
---> 37             return model.Var(name, dist, data, total_size)
38         else:
39             raise TypeError("Name needs to be a string but got: {}".format(name))

~/anaconda3/lib/python3.6/site-packages/pymc3/model.py in Var(self, name, dist, data, total_size)
819             with self:
820                 var = MultiObservedRV(name=name, data=data, distribution=dist,
--> 821                                       total_size=total_size, model=self)
822             self.observed_RVs.append(var)
823             if var.missing_values:

~/anaconda3/lib/python3.6/site-packages/pymc3/model.py in __init__(self, name, data, distribution, total_size, model)
1341         self.missing_values = [datum.missing_values for datum in self.data.values()
1342                                if datum.missing_values is not None]
-> 1343         self.logp_elemwiset = distribution.logp(**self.data)
1344         # The logp might need scaling in minibatches.
1345         # This is done in `Factor`.

<ipython-input-11-bdd19ba5bae4> in MarginalLikelihood(ls, eta, sigma, x, y)
3     cov = eta**2 * ExpQuad(1,ls)(x)
4     log_p1 = -1/2* y*cov*tt.transpose(y)
----> 5     log_p2 = tt.nlinalg.Det(cov)#-1/2*tt.log(tt.nlinalg.Det(cov))
6     log_p3 = -y.size/2*np.log(2*np.pi)
7     return log_p1+log_p2+log_p3

TypeError: object() takes no parameters
``````

Is there anyone who can help to fix the error?

You are not calling the `tt.nlinalg.Det` correctly, it should be `tt.nlinalg.Det()(cov)` - you initialized the theano_op first by doing `tt.nlinalg.Det()`.