How to define a vector-valued variable with different distribution for random its random variables


I know if we want to define distribution for a variable which consists of an array of random variables, we can give the ‘shape’ parameter.

hx=pm.Normal('hx', mu=0, sd=1, shape=(3,3))

In this case all the random variables will have the same distribution (the same mu and sd). Can I assign different mu and sd for these 3*3 random variables repectively?

Thanks very much!

Don’t believe so, but if you want to a 3x3 bundle of variables, you can create one “by hand”, but creating the individual variables (with separate means and SDs) and then bundling them using tt.stack and/or tt.concatenate.

something like:

mu = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
sigma = np.array([[1, 1, 1], [2, 2, 2], [3, 3, 3]])

with pm.Model():
    hx = pm.Normal('hx', mu=mu, sigma=sigma, shape=(3,3))

Thanks very much! It works!

Thanks very much!