[R] mixture normal distributions

aleid2001@yahoo.com aleid2001 at yahoo.com
Fri Feb 10 16:02:09 CET 2006


Dear R helper,

I mange to transform uniform sequences to mixture
normal distributions using the following cods:


> K<-50000
>  prime<-c(29) , where 29 is prim number
> UN<-seq(1:K)%*%t(sqrt(prime))
> U1<-UN-as.integer(UN)
> e<-norMix(mu=c(-0.825,0.275), sig2 = c(0.773,0.773),
w = c(0.25,0.75), name = NULL, long.name = FALSE)
> U<-matrix(qnorMix(e,U1),K,1),

But somtimes if i use ,e.g, 23 or 11 instead of 29 it
will give me the following error. 

> K<-30000
>  prime<-c(23)
> UN<-seq(1:K)%*%t(sqrt(prime))
> U1<-UN-as.integer(UN)
> e<-norMix(mu=c(-0.825,0.275), sig2 = c(0.773,0.773),
w = c(0.25,0.75), name = NULL, long.name = FALSE)
> U<-matrix(qnorMix(e,U1),K,1)
Error in uniroot(function(l) pnorMix(obj, l) - pp[i],
interval = rq) : 
        f() values at end points not of opposite sign


I am seeking help how to avoid this error.

Many thanks for your help in advance.

My E-mail is aleid2001 at yahoo.com

Al-Eid

The university of Manchester.




More information about the R-help mailing list