# Overflow problem

**URL:** <https://discourse.pymc.io/t/overflow-problem/1219>\
**Category:** Questions\
**Created:** [May 14, 2018, 12:17pm UTC](https://discourse.pymc.io/t/overflow-problem/1219 "2018-05-14T12:17:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cabbagee](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/cabbagee/32/660_2.png) [@Cabbagee](https://discourse.pymc.io/u/Cabbagee)\
**Post date:** [May 14, 2018, 12:17pm UTC](https://discourse.pymc.io/t/overflow-problem/1219/1 "2018-05-14T12:17:10Z")

</div>

Hi,everyone，my Bayesian model encountered an overflow problem,

I don’t know how to solve it. any help will be very grateful,my code is as follows:

```
with pm.Model() as model:
    BoundNormal = pm.Bound(pm.Normal, lower=0., upper=1.)
    sigma_w = pm.InverseGamma('sigma_w',1.0,0.1)
    rho = BoundNormal('rho', mu=0.4, sd=0.01)
    cov0=sigma_w**2*tt.pow(rho,H0)

    omega=pm.MvNormal('omega',mu=mu0,cov=cov0,shape=(1,n))    

    mu1=pm.Normal('mu1',mu=0.0,sd=0.01)
    xi=pm.InverseGamma('xi',11.0,0.1)
    b=pm.Normal('b', mu=0.0, sd=tt.sqrt(xi),shape=(N,1))

    mu2=(mu1+b)*e+omega
    sigma=pm.HalfNormal('sigma',0.01)

    y=pm.Normal('y',mu=mu2,sd=sigma,observed=dataSet2)  

with model:
    trace=pm.sample(n=2000,njobs=1)

```

error occurred when sampling was made up to 40%

```
raise ValueError('Mass matrix contains zeros on the diagonal. '

ValueError: Mass matrix contains zeros on the diagonal. Some derivatives might always be zero.
```

---

<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:** [May 14, 2018, 1:20pm UTC](https://discourse.pymc.io/t/overflow-problem/1219/2 "2018-05-14T13:20:38Z")

</div>

If you do a search on the discourse, there are quite a few idea of how to debug it. In general, it is cause by improper prior.

---

<div class="post-metadata">

**Author:** ![Cabbagee](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/cabbagee/32/660_2.png) [@Cabbagee](https://discourse.pymc.io/u/Cabbagee)\
**Post date:** [May 15, 2018, 3:07am UTC](https://discourse.pymc.io/t/overflow-problem/1219/3 "2018-05-15T03:07:18Z")

</div>

Thank you for your guidance. I will search related questions to try to improve my own priori.
