At a rough guess you don't seed your random number generator after you (needlessly) create a new generator object on every pass through the loop: RandomGenerator random;
You presumably mean it produces the same answers twice, not "shows absolute correlation" in a statistical sense.
The following code doesn't compute anything remotely statistical yy = yy + (x[j] - avgx)*(x[j] - avgx)*(y[j] - avgy)*(y[j] - avgy);
and the following looks pretty unlikely notation ("xx") for a product of fluctuations in x and y: xx = xx + (x[j] - avgx)*(y[j] - avgy);
If you want the correlation coefficient then it is
SUM{ (x - xav)*(y-yav) } / SQRT[ SUM{ (x-xav)^2 } * SUM{ (y-yav)^2 } ]
Those are SEPARATE sums of squares in the denominator: you appear to be computing a single sum of a very big product in yy.