s-news
[Top] [All Lists]

Re: expected value of a normal variable with integrate()

To: Agin.Patrick@hydro.qc.ca
Subject: Re: expected value of a normal variable with integrate()
From: Sundar Dorai-Raj <sundar.dorai-raj@PDF.COM>
Date: Mon, 22 Dec 2003 15:23:18 -0600
Cc: s-news@lists.biostat.wustl.edu
In-reply-to: <3B7812F13593D411979200508BE3A75C10A23380@msxcentral2.hydro.qc.ca>
Organization: PDF Solutions, Inc.
References: <3B7812F13593D411979200508BE3A75C10A23380@msxcentral2.hydro.qc.ca>
Reply-to: sundar.dorai-raj@PDF.COM
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)
You need to rescale the density to integrate to one.

What you have below only integrates to 0.5. Try

integrate(function(x) 2 * x * dnorm(x), -Inf, 0)

Regards,
Sundar

Agin.Patrick@hydro.qc.ca wrote:


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>