Creates correlated ability parameters based on an input correlation matrix.
This is a helper function for use in synthesizing multi-dimensional data assuming multivariate normal distribution
correlation_matrix
n_participants
abilities
def create_correlated_abilities(correlation_matrix, n_participants):
""" Creates correlated ability parameters based on an input correlation matrix.
This is a helper function for use in synthesizing multi-dimensional data
assuming multivariate normal distribution
Args:
correlation_matrix: (2d array) Symmetric matrix defining
the correlation between the abilities
n_participants: number of participants to synthesize
Returns:
abilities: (2d array) correlated abilities
"""
lower = np.linalg.cholesky(correlation_matrix)
return lower @ np.random.randn(correlation_matrix.shape[0], n_participants)