Issue with using distributions to build arrays


#1

Hi,

I’m trying to use PyMC3 to do some SED fitting. I have my galaxy age, given by a discrete uniform distribution

gal_age = pm.DiscreteUniform(‘gal_age’,lower=0,upper=13500)

And from there, I want to generate an array from 0 to the age of the galaxy, to get my star formation history later

sfh_steps = np.array(range(gal_age+1))

This works fine if I’m just putting a number as gal_age, but when I run this now I get

TypeError: range() integer end argument expected, got TensorVariable.

Is there any easy way to get this working the way I’d expect?

Cheers,

Tom


#2

You can use theano.tensor.arange which operates like NumPy’s arange:

sfh_steps = tt.arange(gal_age+1)

#3

Excellent, that’s worked, thanks!