5
$\begingroup$

I am trying to understand why lines (1) and (2) give the same result

set.seed(2525); 
n <- 1e6; X <- rnorm(n) 

Lines (1) and (2)

(1) rbind(c(mean(X[X>1]), mean(X*(X>1)), mean(pmax(X-1,0))),
(2) c(dnorm(1)/pnorm(-1), dnorm(1), dnorm(1)-pnorm(-1)))

Result

 [,1]      [,2]       [,3]
[1,] 1.524587 0.2416943 0.08316332
[2,] 1.525135 0.2419707 0.08331547
$\endgroup$
0

1 Answer 1

10
$\begingroup$

The first result simulates the mean of a truncated normal distribution with truncation point 1, whose expected value is, from here and standard normality with $\mu=0$, $\sigma=1$, $$ \mu_T=\frac{\phi(1)}{1-\Phi(1)}=\frac{\phi(1)}{\Phi(-1)}, $$ where the second equality uses symmetry of the standard normal around zero.

The second is the mean of a version of a censored normal distribution with censoring point 1, where, however, the censored values are not replaced with the censoring point but with 0. Hence, the density of the censored distribution can be taken from here.

Since we replace censored values with zeros, they contribute nothing to the expected value, so that we evaluate (see e.g. https://math.stackexchange.com/questions/402215/what-is-int-xe-x2-dx or shorturl.at/eFLO0) $$ \int_1^\infty x\phi(x)dx=\phi(1) $$ Had this been "conventional" censoring, we would have looked at mean(X*(X>1)+1*(X<=1)), which, again via here, would have expectation $$ 1\cdot\Phi(1)+\phi(1). $$

The third problem is basically the same as the second, except that we now evaluate

$$ \int_1^\infty (x-1)\phi(x)dx=\phi(1)-(1-\Phi(1))=\phi(1)-\Phi(-1) $$

$\endgroup$
2
  • 3
    $\begingroup$ @Manbearpig I didn't write the answer. It was Christoph. As usual, if you think the answer helped, do accept it. $\endgroup$ Commented Nov 25, 2022 at 16:32
  • 1
    $\begingroup$ The first is the difficult part. The second is just the first times $1-\Phi(1)$ and the third is the first minus $1$ and the result multiplied by $1-\Phi(1)$ $\endgroup$
    – Henry
    Commented Nov 26, 2022 at 8:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.