Correlation of one random variable and a binary variable dependent on it I create one normal random variable using =NORM.S.INV(RAND()) in Excel and a binary variable =IF(B2>=0,1,0), where B2 is this random variable. If I continously resample, I find that their correlation is approximately 0.4 and covariance 0.8. How can I arrive at these numbers outside of a simulation?
 A: By definition, the covariance of a bivariate random variable $(X,Y)$ is the expected product of their standardized versions.  Let's begin with the standardization, then:


*

*The normal random variable $X$ in the question is already standardized (to a mean of zero and unit variance).

*The other variable, equal to the indicator that $X\ge 0$ (often written $I(X\ge 0)$, is a Bernoulli variate with mean
$$p = \Pr(X \ge 0) = 1/2.$$
Its variance is
$$p(1-p) = 1/4.$$
Therefore its standardized version (obtained by subtracting $p$ and dividing the result by the SD) is
$$\Pr(Y = 1) = 1/2 = \Pr(Y = -1).$$
It remains to find the expectation of
$$XY = |X|.$$
We can do that by integrating $|X|$ against the density of $X$:
$$\mathbb{E}(XY) = \frac{1}{\sqrt{2\pi}}\int_\mathbb{R}|x|\exp(-x^2/2)dx,$$
which is readily performed via the substitution $u = x^2/2$, $du = x dx$ and breaking the integral at $0$ into two equal parts.  Its value is $2$, whence the answer is $$\rho(X,Y)=\frac{2}{\sqrt{2\pi}}\approx 0.797885.$$
The covariance is obtained by multiplying this correlation by both of the standard deviations, one of which is $1$ and the other of which is $1/2$, whence $$\text{Cov}(X,Y) = \frac{1}{\sqrt{2\pi}} \approx 0.398942.$$
As a check, we could generate a lot of $(X,Y)$ pairs--maybe spending a second on this--and report their correlation and covariance.  The following are R commands:
x <- rnorm(1e7)
y <- x >= 0
cov(x,y)
cor(x,y)

The output from this simulation of 10,000,000 pairs is
> cov(x,y)
[1] 0.3988456
> cor(x,y)
[1] 0.7979245

which is accurate to almost four decimal digits.
