Re: [R] Integration of mixed normal distribution

2013-01-30 Thread David Winsemius
On Jan 30, 2013, at 4:19 AM, Johannes Radinger wrote: Hi, I already found a conversation on the integration of a normal distribution and two suggested solutions (https://stat.ethz.ch/pipermail/r-help/2007-January/124008.html): 1) integrate(dnorm, 0,1, mean = 0, sd = 1.2) and 2) pnorm(1, mea

Re: [R] Integration of mixed normal distribution

2013-01-30 Thread Rui Barradas
Hello, You could do something like the following. fun <- function(x, mean, sd1, sd2, p) dnorm(x, mean, sd1)*p + dnorm(x, mean, sd2)*(1 - p) fun2 <- function(x1, x2, mean, sd1, sd2, p){ p1 <- pnorm(x2, mean, sd1) - pnorm(x1, mean, sd1) p2 <- pnorm(x2, mean, sd2) - pnorm(