Reputation: 4264
Is there a way to randomly draw samples from the matrix normal distribution (https://en.wikipedia.org/wiki/Matrix_normal_distribution#Drawing_values_from_the_distribution) using python? Numpy has functionality for drawing from the 1-D normal distribution and the multivariate normal distribution, but I can't find anything on the matrix normal distribution. Thanks.
Upvotes: 1
Views: 1630
Reputation: 571
numpy.random.normal()
could draw 2d matrix as long as you specify size like this:
numpy.random.normal(loc = mean, scale = standard deviation, size = (m,n))
Upvotes: 1
Reputation: 97661
From the wikipedia page you link:
The matrix normal is related to the multivariate normal distribution in the following way:
if and only if
Translated to numpy, that should be
numpy.random.multivariate_normal(M.ravel(), np.kron(V, U)).reshape(M.shape)
Upvotes: 7