In general, you sample the mixture component indicator z from the mixing distribution and then sample from the z-th component of the mixture.
For discrete mixtures, that's 2 calls to GSL: Sample z from gsl_ran_discrete(...) (or even simpler for two-component mixtures), then sample from the z-th component distribution, e.g. x = mu[z] + gsl_ran_gaussian(rng, sigma[z]). -- mj On Thu, Oct 2, 2008 at 09:52, Rodney Sparapani <[EMAIL PROTECTED]> wrote: > Jun Yang wrote: >> >> Hi, >> >> How to use GSL to sample from mixture distribution such as a Gaussian >> mixture? Thanks. >> >> >> Best Regards, >> >> Jun Yang > > I don't think there is a GSL routine for this. But, that's probably just as > well. Normally, the way you do this is you have 3 PRNG streams: a > Bernoulli and 2 different Gaussians. If the Bernoulli is zero, then you > sample from one Gaussian, otherwise, the other. > > Rodney > > > > _______________________________________________ > Help-gsl mailing list > [email protected] > http://lists.gnu.org/mailman/listinfo/help-gsl > _______________________________________________ Help-gsl mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-gsl
