# Thread: Variables with set variance and mean

1. ## Variables with set variance and mean

I need to test if ratio variables made from uncorrellated/correlated
variables are correlated. I have three questions:

1) Should I generate uniformely distributed variables e.g. X=rand
(50,1) or normally distributed variables by using RANDN?

2) How can I generate a matrix of 50-by-1 containing numbers with a
predefined mean and variance?

3 Is it possible to predetrmine "the correlation level" of the
variables in the matrix. For example to create a matrix of 50-by-1
with correlation coeffecient of 0.70 (is this possible also if mean
and variance are predefinied)?

2. Originally Posted by BR20
I need to test if ratio variables made from uncorrellated/correlated
variables are correlated. I have three questions:

1) Should I generate uniformely distributed variables e.g. X=rand
(50,1) or normally distributed variables by using RANDN?

2) How can I generate a matrix of 50-by-1 containing numbers with a
predefined mean and variance?

3 Is it possible to predetrmine "the correlation level" of the
variables in the matrix. For example to create a matrix of 50-by-1
with correlation coeffecient of 0.70 (is this possible also if mean
and variance are predefinied)?
In what language?

CB

3. I'm using MatLab.

BR

4. Originally Posted by BR20
I need to test if ratio variables made from uncorrellated/correlated
variables are correlated. I have three questions:

1) Should I generate uniformely distributed variables e.g. X=rand
(50,1) or normally distributed variables by using RANDN?

2) How can I generate a matrix of 50-by-1 containing numbers with a
predefined mean and variance?

3 Is it possible to predetrmine "the correlation level" of the
variables in the matrix. For example to create a matrix of 50-by-1
with correlation coeffecient of 0.70 (is this possible also if mean
and variance are predefinied)?
1. Use normals since then it is easier to generate correlated RVs

2. x=randn(50,1)*sigma+mean

3. xx=lambda*x+[0;rho*x(1:length(x)-1)] will give correlated RV's but you will have to sort out what lambda and rho have to be to give the required mean and SD and correlation coefficient.

CB

5. Thanks!

2) so if i want to create normally distributed variables with mean=20 and variance= 10, the matrix is produced by X=randn(50,1)*20+sqrt(10)

3) since i'm not a matlab expert, could you please clear the syntax for me. I'd really appreciate it. how would i create a matrix of 50-by-1 where the correlation coeffecient is e.g. 0.7?