# question with integrate function

4 messages
Open this post in threaded view
|

## question with integrate function

 Hi all,   The function h below is a function of c and it should be a monotone increasing function since the integrand is nonnegative and integral is taken from c to infinity. However, as we can see from the plot, it is not shown to be monotone. Something wrong with the usage of integrate function? Thanks so much for your help.     Hanna h <- function(c){     g <- function(x){pnorm(x-8.8, mean=0.4, sd=0.3, lower.tail=TRUE)*dnorm(x, mean=9,sd=0.15)}     integrate(g, lower=c, upper=Inf)\$value} xx <- seq(-20,20,by=0.001) y <- xx for (i in 1:length(xx)){y[i] <- h(xx[i])} plot(xx, y)         [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: question with integrate function

 Sorry. I meant in the previous email that the function h() is a monotone decreasing function. Thanks very much. 2018-02-06 13:32 GMT-05:00 li li <[hidden email]>: > Hi all, >   The function h below is a function of c and it should be a monotone > increasing function since the integrand is nonnegative and integral is > taken from c to infinity. However, as we can see from the plot, it is not > shown to be monotone. Something wrong with the usage of integrate function? > Thanks so much for your help. >     Hanna > > > > h <- function(c){ >     g <- function(x){pnorm(x-8.8, mean=0.4, sd=0.3, > lower.tail=TRUE)*dnorm(x, mean=9,sd=0.15)} >     integrate(g, lower=c, upper=Inf)\$value} > > xx <- seq(-20,20,by=0.001) > y <- xx > for (i in 1:length(xx)){y[i] <- h(xx[i])} > plot(xx, y) > >         [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.