5
如何使用Cholesky分解或其他方法进行关联数据模拟
给定相关矩阵,我使用Cholesky分解来模拟相关的随机变量。问题是,结果永远不会像给出的那样重现相关结构。这是Python中的一个小例子来说明这种情况。 import numpy as np n_obs = 10000 means = [1, 2, 3] sds = [1, 2, 3] # standard deviations # generating random independent variables observations = np.vstack([np.random.normal(loc=mean, scale=sd, size=n_obs) for mean, sd in zip(means, sds)]) # observations, a row per variable cor_matrix = np.array([[1.0, 0.6, 0.9], [0.6, 1.0, …