Categorical Prior Distribution

In an attempt to solve a more complex model, I have created simple toy model below. It uses a categorical prior and Poisson prior distribution. It seems to me that the chain should converge on 6, that is twice the obs value, but it does not move from zero. I feel I must have overlooked something very obvious, as I have used categorical priors before.

import numpy as np
from pymc3 import *
from pymc3.distributions.discrete import Poisson, Categorical
import theano
import theano.tensor as tt
%matplotlib inline
import matplotlib
import matplotlib.pyplot as plt

def run_true_MCMC(n, obs, draws):
    obs = np.array(obs)
    with Model() as model2: 
        pn = np.ones(n) / n
        tmx = Categorical('tmx', pn)  
        tmx = tmx * 0.5
        #tmx_print = tt.printing.Print('tmx')(tmx)  
        sfs_obs = Poisson('sfs_obs', mu=tmx, observed=obs) 

    with model2:
        trace = sample(draws, tune=0)  #Will set to CategoricalGibbsMetropolis, varnames=['tmx']))
    traceplot(trace, varnames=['tmx'])
    print(summary(trace, varnames=['tmx']))
    return trace

obs = 3
draws = 100000
n = 10
trace = run_true_MCMC(n, obs, draws)

It could be a bug - did you try to set the testval to different number?

tmx = Categorical('tmx', pn, testval=2)  

Yes, with a non-zero testval it works! Why should this be?

Likely a edge case for CategoricalGibbsMetropolis - I come across it a couple of times. could you please raise an issue on Github?

Could it be related to this other issue?

I dont think so, this error is when using CategoricalGibbsMetropolis, the other one is when using ElemwiseCategorical

Thanks Junpeng, I will raise an issue as you say.