Hi,

Many thanks for the explanation.

Alberto Monteiro wrote:

>
>PS: fff <- function(x) 1 
>integrate(fff, 0, 1)  # error. why?
>

Guess: because integrate itself expects a "vectorized function" ?

 > fff(1:5)
[1] 1
 > ggg<-function(x) { sapply(x, function(x)1) }
 > ggg(1:5)
[1] 1 1 1 1 1
 > integrate(ggg,0,1)
1 with absolute error < 1.1e-14
 > hhh<-function(x) 1+0*x
 > integrate(hhh, 0, 1)
1 with absolute error < 1.1e-14

I sense a certain lack of intuitiveness here :-/


regards, Theo

______________________________________________
[email protected] 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.

Reply via email to