# Random number generation for correlated variables

Hi All,

Thanks for the wonderful software and swift response on this platform. Please I will like to find out if it is possible to generate random numbers for correlated random variables using Uqlab.

For example, I have three variables all uniformly distributed A(26,33)kN ; B(2,3.5)cm ; C(60,120) kg. Correlation between variables are A/B=0.5 , B/C=0.65 and A/C =0.9. How can I generate say 200 random numbers such that this correlation exist between the variables?

Can I achieve this using Uqlab and any necessary direction and necessary steps will be highly appreciated.

Season’s greetings

Okoro

Hi @aokoro,

Yes, this can be done in different ways. For example, you can use the following code:

``````Input.Marginals(1).Name = 'A';
Input.Marginals(1).Type = 'Gaussian';
Input.Marginals(1).Parameters = [26 33];

Input.Marginals(2).Name = 'B';
Input.Marginals(2).Type = 'Gaussian';
Input.Marginals(2).Parameters = [2 3.5];

Input.Marginals(3).Name = 'C';
Input.Marginals(3).Type = 'Gaussian';
Input.Marginals(3).Parameters = [60 120];

Input.Copula.Type = 'Gaussian';
Input.Copula.RankCorr = ...
[1 0.5 0.9;...
0.5 1 0.65;...
0.9 0.65 1];
myInput = uq_createInput(Input);
``````