Using Python, how can I sample data from a multivariate log-normal distribution? For instance, for a multivariate normal, there are two options. Let's assume we have a 3 x 3 covariance matrix and a 3-dimensional mean vector mu.
# Method 1
sample = np.random.multivariate_normal(mu, covariance)
# Method 2
L = np.linalg.cholesky(covariance)
sample = L.dot(np.random.randn(3)) + mu
I found numpy's numpy.random.lognormal, but that only seems to work for univariate samples. I also noticed scipy's scipy.stats.lognorm. This does seem to have the potential for multivariate samples. However, I can't figure out how to do this.
r = lognorm.rvs(s, size=1000)returns a list of 1000 random variables. s is a floating point number (a seed, I suppose), Why won't that do what you want? - Paul Corneliussis not a seed; it is the shape parameter of the distribution. - Warren Weckesser