Hi all, Can anyone please take a look at the following two functions. The answer does not seem to be right. Thank you very much!
f1 <- function(x) {integrand <- function (x, mu){ dnorm(x, mean=mu, sd=1)*dnorm(mu, mean=2, sd=1) } integrate(integrand, -Inf, Inf,x)$val } f2 <- function(x) {integrand <- function (x, mu){ dnorm(x, mean=mu, sd=1)*mu^2*dnorm(mu, mean=2, sd=1) } integrate(integrand, -Inf, Inf,x)$val } [[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 and provide commented, minimal, self-contained, reproducible code.