[R] Difference in mixture normals and one density

Liaw, Andy andy_liaw at merck.com
Mon Apr 4 16:24:15 CEST 2011


Is something like this what you're looking for?

R> library(nor1mix)
R> nmix2 <- norMix(c(2, 3), sig2=c(25, 4), w=c(.2, .8))
R> dnorMix(1, nmix2) - dnorm(1, 2, 5)
[1] 0.03422146

Andy

> -----Original Message-----
> From: r-help-bounces at r-project.org 
> [mailto:r-help-bounces at r-project.org] On Behalf Of Jim Silverton
> Sent: Monday, April 04, 2011 10:01 AM
> To: r-help at r-project.org
> Subject: Re: [R] Difference in mixture normals and one density
> 
> Hello,
> I am trying to find out if R can do the following:
> 
> I have a mixture of normals say f = 0.2*Normal(2, 5) + 0.8*Normal(3,2)
> How do I find the difference in the densities at any 
> particular point of f
> and at Normal(2,5)?
> 
> -- 
> Thanks,
> Jim.
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at 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.
> 
Notice:  This e-mail message, together with any attachme...{{dropped:11}}



More information about the R-help mailing list