About settings in MvNormal()

Dear Pymc3 experts,
Assumuing I have a matrix whose size is [n * k], this matrix acts as the mean of multivariate normal distribution, k is the number of means, n is the number of data points, so the size of covariance matrix is [k * k]. And I want to sample from this multivariate normal distribution so that I have [n * k * m] parameters,how should I manage to do that?The thing I want to do in python is like:

mu = np.ones([n,k])
cov = np.ones([k,k])
sample_parameter =  np.zeros([n,k,m])
for i in range(n):
     sample_parameter[i,:,:] = np.random.multivariate_normal(mu[i,:],cov,m)

Thank you very much.

Could you say more about what you need? Have you checked out the examples here?

1 Like

Thank you for your reply. Sorry I did not explain my problem properly. I think my problem is similar with this one
matrix whose size is [n * k], k is the number of means, n is the number of data points, so the size of covariance matrix is [k * k]. The thing I want to do in python is like:

mu = np.ones([n,k])
cov = np.ones([k,k])
sample_parameter =  np.zeros([n,k,m])
for i in range(n):
     sample_parameter[i,:,:] = np.random.multivariate_normal(mu[i,:],cov,m)

How should I do this thing in Pymc3? Thank you very much.

If you follow the code that @junpenglao wrote in that thread, you should be able to sample from the parameters like this:

prior = pm.sample_prior_predictive()
print(prior['Mv'])
1 Like