Two correlated random variables
15 views (last 30 days)
Show older comments
I want a formula to generate two random variables X and Y that are correlated with a certain rho and distributed (0, 1). The formula provided by all the sources I saw is (a few are provided below) is:
rho = 0.9; %for example
x = rand(); X = x;
y = rand();
Y = rho*X + sqrt(1-rho^2)*y;
However, the Y values generated are not distributed between 0 and 1 (however, the corelation is correct). Please see the attahced image. Does anyone have a better formula? Thanks.
https://www.quantstart.com/articles/Generating-Correlated-Asset-Paths-in-C-via-Monte-Carlo
Answers (0)
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!