Thomas,

Thanks for enlighting me about using pnorm.The reason I was going to
use the double integral was for  the cumulative distribution fuction F(X)
in the formula. I just tried your method, and  it worked which saved me a
lot of time.

Thanks.

Kyong

On Thu, Dec 6, 2012 at 3:41 PM, Thomas Stewart <tgs.public.mail@gmail.com>wrote:

> Kyong-
>
> It isn't clear to me why are you using a double integral.  You have the
> pdf and your goal is to calculate the expected value of a univariate random
> variable (the first order statistic).
>
> Shouldn't the expected value be  E[X_(1)] = int x * 5 * f(x) * (1-F(x))^4
> dx ?  A single integral?
>
> Here are two different numerical techniques to calculate the expected
> value.
>
> -tgs
>
>  fff <- function(x) 5 * x * dnorm(x) * (1 - pnorm(x))^4
> integrate(fff,-Inf,Inf)
>
> M <- 100000
> N <- 5
> D <- matrix(rnorm(M*N),nrow=M)
> mean(apply(D,1,min))
>
>
>  On Thu, Dec 6, 2012 at 1:14 PM, kyong park <kpypark@gmail.com> wrote:
>
>>  Hi  R users,
>>
>>
>>
>>  I’d like to get an expected value for  a minimum value from order
>> statistics of sample size, say, 5 for standard normal distribution, and
>> the
>> formula would be 5* Integral (from -inf  to Inf) x*f(x)* (1-F(x))^4,where
>> f(x) and F(x) are a standard normal density  and a cumulative distribution
>> function respectively. After searching R posts, I applied the following
>> double integral formula which gave an error message saying “the integral
>> is
>> probably divergent.”
>>
>>
>>
>>  integrate(function(y){
>>
>>
>>
>> + sapply(y,function(y){
>>
>>
>>
>> +
>>
>> integrate(function(x)5*y*(1/sqrt(2*pi))*exp(-y^2/2)*(1-(1/sqrt(2*pi))*exp(-x^2/2))^4,-Inf,y)$value})
>>
>>
>>
>> + },-Inf,Inf)
>>
>>
>>
>> I’m  not sure whether the syntax  is correct or not. Appreciate your help.
>>
>>
>>
>> Kyong
>>
>>         [[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<http://www.r-project.org/posting-guide.html>
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>

	[[alternative HTML version deleted]]


