Re: [R] a problem about integrate function in R .thank you .

2009-10-23 Thread andrew
I don't seem to get a problem with this. Have you tried a Monte Carlo approach to verify that you are getting incorrect answers? For me, I get when the upper is 1 that > integrate(e2, lower = 0, upper = 1) -0.2820948 with absolute error < 5e-05 > sum(e2(runif(1)))/1 [1] -0.2825667 whic

[R] a problem about integrate function in R .thank you .

2009-10-22 Thread fuzuo xie
e2 <- function(x) { out <- 0*x for(i in 1:length(x)) out[i] <-integrate(function(y) qnorm(y),lower=0,upper=x[i])$value out } integrate(e2,lower=0, upper=a)$value above is my code , when a is small , say a<0.45 the result is right . however , when a>0.5 the result is incorrect .