s-news
[Top] [All Lists]

expected value of a normal variable with integrate()

To: s-news@lists.biostat.wustl.edu
Subject: expected value of a normal variable with integrate()
From: Agin.Patrick@hydro.qc.ca
Date: Mon, 22 Dec 2003 16:10:11 -0500

Hi,

Could anyone tell me why the two following expressions don't give the same result:

integrate(function(x) x*dnorm(x),-Inf,0) equals -0.3989
and
tmp <- rnorm(1000000); mean(tmp[tmp<0]) approximately equals -0.79 (two times -0.3989)

I noticed that -0.3989 is the result of mean(pmin(0,tmp)), the mean of all the normal deviates with a cap of zero.

If I'm interested in the expected value of all the negatives under the standard normal, the good result seems to be -0.79. Am I wrong? Why the integrate() _expression_ above doesn't give this number?

Thank you,
Patrick

P.S. I'm using S-Plus 4.5 on Windows XP.

<Prev in Thread] Current Thread [Next in Thread>