Calculating functions of truncated and censored normal variables

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


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.
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).$$
$$\int_1^\infty (x-1)\phi(x)dx=\phi(1)-(1-\Phi(1))=\phi(1)-\Phi(-1)$$
• 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)$ Commented Nov 26, 2022 at 8:19