#### You've reached the end of your free preview.

Want to read both pages?

**Unformatted text preview: **N(x; mu2, sigma2)` at `x`. The sigma here is the standard deviation. #' You can assume that 0 <= c1 <= 1, 0 <= c2 <= 1, c1 + c2 = 1, sigma1 > 0, sigma2 > 0. ## Do not modify this line! my_mixture<-function(x, c1, mu1, sigma1, c2, mu2, sigma2){ return(c1*dnorm(x,mean=mu1,sd=sigma1)+c2*dnorm(x,mean=mu2,sd=sigma2)) } #' 4. Implement a function `mixture_factory(c1, mu1, sigma1, c2, mu2, sigma2)`. This function makes a function that evaluates the probability density function `p(x) = c1 x N(x; mu1, sigma1) + c2 x N(x; mu2, sigma2)`. The sigma here is the standard deviation. #' You can assume that 0 <= c1 <= 1, 0 <= c2 <= 1, c1 + c2 = 1, sigma1 > 0, sigma2 > 0. Use the functions `force` and `dnorm`. ## Do not modify this line! mixture_factory<-function(c1, mu1, sigma1, c2, mu2, sigma2){ force(c1) force(mu1) force(sigma1) force(c2) force(mu2) force(sigma2) function(x){ return(c1*dnorm(x,mean=mu1,sd=sigma1)+c2*dnorm(x,mean=mu2,sd=sigma2)) } }...

View
Full Document

- Fall '18
- Linxi Liu
- Normal Distribution, Variance, Probability theory, probability density function