# Special distribution

#### menahg

##### New Member
Hi,
I have a list of items each having a value between 0 and 1. I want to add another value to each item such that the new value is negatively/positively correlated with the first value.
The new value should be between 0 and 5.
Is there any formula that I can use for that? I would appreciate your help.

Thanks

#### Karabiner

##### TS Contributor
What do you mean - do you want to add a number from 0 to 5, and the resulting
sum should be positively or negatively correlated (how much?) with the initial
variable? Or, do you mean that the variable containing the numbers from
0 to 5 should be correlated with the initial variable, and that variable should be

With kind regards

Karabiner

#### menahg

##### New Member
What do you mean - do you want to add a number from 0 to 5, and the resulting
sum should be positively or negatively correlated (how much?) with the initial
variable? Or, do you mean that the variable containing the numbers from
0 to 5 should be correlated with the initial variable, and that variable should be

With kind regards

Karabiner
Sorry that I could not explain the problem clearly. I mean there is a variable X that holds 9000 values, each value is a tuple (i,j), and i is already known. I want to generate j to be correlated with i.
i is between 0 and 1 and the values were computed based on a given data.
j should be random between 0 and 5
such that:
1) j is positively correlated with i
2) j is negatively correlated with i

#### katxt

##### Well-Known Member
This sort of works, if it is what you are looking for.
X is the variable you start with on (0, 1) and rho is the desired correlation
If rho>0 then make Y = rho*X + sqrt(1-rho^2)*Z where Z is uniform (0, 1)
Y is now correlated with X with correlation rho. Y is on (0, sqrt(2)) and can be scaled to (0, 5) by *5/sqrt(2)
If rho<0 then use Y = |rho|*(1-X) + sqrt(1-rho^2)*Z
(I think.)

#### katxt

##### Well-Known Member
New version, in Excel formulas
Y =NORMSDIST(rho*NORMSINV(X)+SQRT(1-rho^2)*NORMSINV(RAND()))
Y and X are correlated with correlation rho and both lie on (0,1). You can scale Y to (0,5).

#### katxt

##### Well-Known Member
Y = rho*X + sqrt(1-rho^2)*Z is true for X, Y and Z standard normal and so could be roughly true (I think) for uniform.
The second version is an attempt to convert the normal formula into uniform distributions.