Hi all, I am trying to find the expectation of x^1/2 where x~N(a,b) ( Normal with mean a and variance b). Any feedback would be highly appreciated. Have great day ! Haneef [[alternative HTML version deleted]]
Dear Haneef, Pls see if this suits your requirement. sim.norm = rnorm(10000,mean=a,sd=sqrt(b)) mean.est = mean(sqrt(sim.norm)) Thx S. On Sat, Apr 10, 2010 at 9:31 PM, Haneef Anver <haneef9@yahoo.com> wrote:> Hi all, > > > I am trying to find the expectation of x^1/2 where x~N(a,b) ( Normal with > mean a and variance b). > Any feedback would be highly appreciated. > > Have great day ! > > Haneef > > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
On Sat, 10 Apr 2010, Haneef Anver wrote:> Hi all, > > > I am trying to find the expectation of x^1/2 where x~N(a,b) ( Normal with mean a and variance b). > Any feedback would be highly appreciated.Start by constructing plots of x vs Re(sqrt(x)) and x vs Im(sqrt(x)) for -1 < x < 1. Do it by hand. With that plot as a hint you will see how to use integrate() to find the answer. See ?integrate BTW, you can get both the real and imaginary compoenents with one call to integrate(). HTH, Chuck> > Have great day ! > > Haneef > > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >Charles C. Berry (858) 534-2098 Dept of Family/Preventive Medicine E mailto:cberry at tajo.ucsd.edu UC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901
Haneef Anver <haneef9 <at> yahoo.com> writes:> I am trying to find the expectation of x^1/2 where x~N(a,b) > ( Normal with mean a and variance b). > Any feedback would be highly appreciated.I have no idea at the moment how to start doing this analytically, but is this at all helpful?> mean(sqrt(complex(re=rnorm(1000000))))[1] 0.4114712+0.4103866i
Chuck showed how to do this: fn <- function(x) sqrt(x) * dnorm(x)> integrate(fn, 0, Inf)0.4110895 with absolute error < 4.7e-05>So the (almost) exact answer is 0.4110895 + 1i * 0.4110895 Ravi. ____________________________________________________________________ Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvaradhan at jhmi.edu ----- Original Message ----- From: Ben Bolker <bolker at ufl.edu> Date: Sunday, April 11, 2010 1:00 am Subject: Re: [R] Expectation of E(x^1/2) To: r-help at stat.math.ethz.ch> Haneef Anver <haneef9 <at> yahoo.com> writes: > > > I am trying to find the expectation of x^1/2 where x~N(a,b) > > ( Normal with mean a and variance b). > > Any feedback would be highly appreciated. > > I have no idea at the moment how to start doing > this analytically, but is this at all helpful? > > > mean(sqrt(complex(re=rnorm(1000000)))) > [1] 0.4114712+0.4103866i > > ______________________________________________ > R-help at r-project.org mailing list > > PLEASE do read the posting guide > and provide commented, minimal, self-contained, reproducible code.