lundi 29 août 2016

Excel VBA: Generating correlated random variables with given means and standard deviations

I'm trying to generate correlated random variables (more than 3) with given means and standard deviations in excel.

The current logic is:

1) Using Cholesky algorithm get the lower triangular matrix (Chol_matrix). The function works correctly, cross checked with online calculators. 2) Generate random values for the variables with means and standard deviations using

var1 = WorksheetFunction.Norm_Inv(Rnd, , ) var2 = WorksheetFunction.Norm_Inv(Rnd, , ) ... varN = WorksheetFunction.Norm_Inv(Rnd, , )

3) Multiply randomly generated numbers to Chol_matrix by Application.MMult(var1_to_N, Chol_matrix) to get the correlated variables

However, when testing the results, the data series for variables don't have the means and standard deviations which were set when generating them.

Is it even possible to achieve what I need?

Thank you




Aucun commentaire:

Enregistrer un commentaire