from pymc import Bernoulli, MCMC

def generate_timesteps(N, p_init, p_trans):
    timesteps = np.empty(N, dtype=object)
timesteps[0] = Bernoulli('T0', p_init)
for i in range(1, N):
    p_i = p_trans[1] * timesteps[i - 1] + p_trans[0] * (1 - timesteps[i - 1])
timesteps[i] = Bernoulli('T%d' % i, p_i)
return timesteps
timesteps = generate_timesteps(10, 0.8, [0.001, 0.5])
model = MCMC(timesteps)
model.sample(10000)
[np.mean(model.trace(t).gettrace()) for t in timesteps]
How can I make a discrete state Markov model with pymc?