Generate correlated data in Python (3.3)
In R there is a function ( cm.rnorm.cor , from package CreditMetrics ), that takes the amount of samples, the amount of variables, and a correlation matrix in order to create correlated data. Is there an equivalent in Python? numpy.random.multivariate_normal is the function that you want. Example: import numpy as np import matplotlib.pyplot as plt num_samples = 400 # The desired mean values of the sample. mu = np.array([5.0, 0.0, 10.0]) # The desired covariance matrix. r = np.array([ [ 3.40, -2.75, -2.00], [ -2.75, 5.50, 1.50], [ -2.00, 1.50, 1.25] ]) # Generate the random samples. y = np