[R] integral of the fuction for each value

Tobias Fellinger tobby @end|ng |rom htu@@t
Sun Oct 21 14:23:07 CEST 2018


I'm not entirely sure what you want to calculate. 

If you want to integrate by u in the interval from 0 to 4 for every value
of x I would suggest something like this:

x <- rnorm(10,0,1)
f <- function(u,x){

sapply(x, function(i){
  integrate(f,lower=1,upper=4, x=i)$value

You can just pass additional arguments to f to integrate, integrate always
integrates by the first argument of the function passed as its first
argument, see the help entry of integrate for more details.

Best Regards, Tobias

On Sun, 2018-10-21 at 12:02 +0000, malika yassa via R-help wrote:
> hello
> please you help me i have this functionx<-rnorm(10,0,1)f<-fuction(u,x)  {exp((x-u)}I want to calculate the integral of this function for each value of x{for(i in 1:lenght(x)integrate(f,lower=1,upper=4) 
> thinks
> 	[[alternative HTML version deleted]]
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

More information about the R-help mailing list