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: Spencer Graves <spencer.graves@pdf.com>
Date: Mon, 22 Dec 2003 13:22:42 -0800
Cc: s-news@lists.biostat.wustl.edu
In-reply-to: <3B7812F13593D411979200508BE3A75C10A23380@msxcentral2.hydro.qc.ca>
References: <3B7812F13593D411979200508BE3A75C10A23380@msxcentral2.hydro.qc.ca>
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)
The density of the half-normal distribution you simulate is 2*dnorm, not dnorm: Over that interval, dnorm(x) integrates to 0.5. You must multiply it by 2 to so it integrates to 1. . hope this helps. spencer graves

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>