Looping in pymc3/theano

Thanks @ricardoV94 . Looign forward to the new version. In any case, I ended up doing it without scan(), just creating a list of variables in a for loop. It’s probably much slower than the scan solution, as it ends up creating many variables that will be estimated, but it works.

I am leaving it here or reference, as it may help others:

ps =[ pm.Binomial("n0",popsize,p0_,shape=data.shape[0])/popsize ]

for n in range(1,24):
  nextp = ps[n-1]
  ps.append(pm.Binomial("n"+str(n),popsize,nextp,shape=data.shape[0])/popsize )

Importantly, you need to specify the shape, when you use Binomials like this…

1 Like