Skip to content
Prev 86238 / 398502 Next

mixture normal distributions

you forgot to mention the important fact that you are working
with package  "nor1mix"  (of which I am the maintainer which you
could have seen from   library(help = nor1mix)  or 
packageDescription("nor1mix")
This looks like you want to generate pseudo-random values from
the mixture distribution.

However by the slowest most possible way:  qnorMix() is really
slow because it calls uniroot() for each value.

rnorMix() will generate random values distributed according to
the normal mixture very very efficiently (particularly compared
to using qnorMix()).

But indeed, you have detected a bug in qnorMix() 
(that happens pretty rarely).  Indeed your example also shows
that the algorithm can be much improved in some cases.

The next verion of nor1mix  should  contain a more "robust"
qnorMix() function.