[R] Expectation of E(x^1/2)
Ben Bolker
bolker at ufl.edu
Sun Apr 11 07:09:31 CEST 2010
And Mathematica says
In[2]:= 1/Sqrt[2 Pi] Integrate[Exp[-x^2/2] Sqrt[x],{x,0,Infinity}]
3
Gamma[-]
4
Out[2]= -------------
3/4
2 Sqrt[Pi]
(I suppose there's probably a change-of-variables trick to do this ...)
in R:
> gamma(3/4)/(2^(3/4)*sqrt(pi))
[1] 0.4110895
Ravi Varadhan wrote:
> 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
>
More information about the R-help
mailing list