generated two, specific random variables with a correlation

I would like to know which is the best method to do the following: - generate a random variable $Y$ over $Z_2$ (possibly following a Bernoulli distribution) such that $Y$ has correlation $\rho$ with a random variable $X$ following the uniform distribution over $Z_2^k$?

I.e., If $x \in X$ is uniformed sampled over $Z_2^{k}$, then I want to generate $y \in Y$ over $Z_2$ such that $\mathrm{Corr}(X,Y)$ is a fixed, given $\rho$? If possible, I'd like $Y$ to follow a Bernoulli distribution.

As standard, $Z_2=\{0,1\}$ and $Z_2^{k}=\{(x_1,..., x_i,,..., x_k) | x_i \in \{0,1\}\}$.

• You need to put the math between dollar signs to get the Latex to display - e.g. $x$ produces $x$ Commented Jun 27, 2016 at 15:56
• Please say in the question what is $Z$, $Z_2^k$. Commented Jun 27, 2016 at 17:43
• How do you define correlation between a random vector and a random scalar? Commented Jun 28, 2016 at 2:01
• $Z_2$=${0,1}$, $Z_2^k$=$\{0,1\} \times ... \times \{0,1\}$ (k times). As for correlation between a variable over $Z_2$ and one over $Z_2^k$, I think it is in fact cross-correlation, to be correct. Commented Jun 28, 2016 at 13:55
• So $\rho$ is a vector, nor a number. Commented Jun 28, 2016 at 18:26

I will provide solutions to two different interpretations of your question. I don't claim that they are the only or the best solutions.

Every place in which independent Bernoulli is mentioned below, it is to be independent of everything else (all other Bernoullis).

Interpretation A: $X$ has a Bernoulli distribution having success probability $0.5$.

Solution:

Step 1. Generate $X$ per Bernoulli distribution having success probability $0.5$.

Step 2.

If $\rho \ge 0$, then for each sample of $X$, set $Y = X$ with probability $\rho$ (i.e., per independent Bernoulli having success probability $\rho$), otherwise set $Y$ = independent Bernoulli having success probability $0.5$.

If $\rho \lt 0$, then for each sample of $X$, set $Y = 1-X$ with probability $-\rho$ (i.e., per independent Bernoulli having success probability $-\rho$), otherwise set $Y$ = independent Bernoulli having success probability $0.5$.

Result: $Y$ has a Bernoulli distribution having success probability $0.5$, and $\text{Corr}(X,Y) = \rho$.

Interpretation B: $X$ has a Bernoulli distribution having success probability $b$, and $Y$ must also have a Bernoulli distribution having success probability $b$, with $\text{Corr}(X,Y) = \rho$.

Solution is provided for $\rho \ge 0$ (note that solution for $\rho \lt 0$ and $b = 0.5$ is provided under Interpretation A; otherwise things are problematic).

Step 1. Generate $X$ per Bernoulli distribution having success probability $b$.

Step 2. For each sample of $X$, set $Y = X$ with probability $\rho$ (i.e., per independent Bernoulli having success probability $\rho$), otherwise set $Y$ = Independent Bernoulli having success probability $b$.

Result: $Y$ has a Bernoulli distribution having success probability $b$, and $\text{Corr}(X,Y) = \rho$.