s-news
[Top] [All Lists]

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

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

Thanks to Sam Buttrey, Bill Dunlap, Spencer Graves, Sundar Dorai-Raj, Terry Therneau and Ping Zhang who answered so quickly and were unanimous in identifying my mistake:

****************************************
dnorm(x) on (-Inf,0) integrates to 1/2, not 1, so you need
to divide by that.  E.g., for the interval (1, 2) you would
do
   integrate(function(x) x*dnorm(x),1,2)$integral / integrate(function(x)dnorm(x),1,2)$integral
   [1] 1.383169

(In this case you can use pnorm() instead integrating dnorm.)
****************************************

Again thank you and best wishes!
Patrick

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