2
$\begingroup$

I have 100,000 random samples (with replacement) X_i from an otherwise unknown distribution.

I want to create a series Y_i that

  1. is the same as X_i except for the ordering and
  2. gives a correlation between X and Y of some given number (or a correlation close to that given number).

Is there a known technique/procedure/algorithm for this?

$\endgroup$
4
  • $\begingroup$ 1) Correlation here means Pearson correlation? $\tag*{}$ 2) You are aware that the range of possible correlations depends on the marginal distribution? And "some given number" here means "some given attainable number"? $\endgroup$
    – g g
    Commented Dec 31, 2022 at 16:00
  • $\begingroup$ @gg Yes. Not sure how this is relevant. Yes (or a number close to that). As an example: if I have X = [1, 2, 3, 4, 5, 6, 28, 2, 4], I want to find a Y consisting of the same numbers but in a different order that gives me a correlation between X and Y of 0.8. $\endgroup$
    – Řídící
    Commented Dec 31, 2022 at 18:21
  • $\begingroup$ I doubt a correlation of $0.8$ is possible in your example: Y = [1, 2, 3, 4, 5, 28, 6, 2, 4] seems to give a correlation less than $0.14$ while Y = [6, 5, 4, 3, 2, 1, 28, 4, 2] seems to give a correlation greater than $0.93$ $\endgroup$
    – Henry
    Commented Jan 2, 2023 at 2:33
  • $\begingroup$ With a less extreme example (the $28$ is the killer) just take many permutations of parts (varying lengths) of the original sequence and choose the one closest to your target correlation. $\endgroup$
    – Henry
    Commented Jan 2, 2023 at 2:41

1 Answer 1

1
$\begingroup$

The following is a quick and dirty solution which may or may not be appropriate in your situation. In what follows $N$ is the sample size.

  1. Create a bivariate normal sample of size $N$ with the desired correlation. $(Z_1, Z_2)$
  2. Register the relative ranks (or order statistics) of $(Z_1,Z_2)$ this provides you with a bivariate Vektor of ranks $(U_1, U_2).$
  3. Register the ranks of your sample $X$.
  4. Create $Y$ by choosing from $X$ so that the ranks of $(X,Y)$ are the same as $(U_1, U_2).$

For various reasons the procedure is not (and cannot be) exact, but in many cases it should work quite well and is easy to implement.

$\endgroup$
1
  • $\begingroup$ Nice! I think that would work in my situation. $\endgroup$
    – Řídící
    Commented Jan 3, 2023 at 4:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .