random numbers from custom mixture distribution
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Venkatessh
il 6 Ott 2013
Risposto: Roger Stafford
il 6 Ott 2013
I would like to generate random numbers from a mixture distribution defined as,
pdf_mix = p*gampdf(x,a,b) + (1-p)*lognpdf(x,mu,sigma);
I am able to obtain the best fit model using mle, but I also want random numbers generated from this mixture distribution. Is this possible? Can I get some help on this?
R Venkatessh
0 Commenti
Risposta accettata
Roger Stafford
il 6 Ott 2013
Here's another method you might consider that would allow you to directly use the 'gamrnd' and 'lognrnd' functions in the Statistics Toolbox. Suppose you want an m by n matrix, R, of random values in accordance with your mixed distribution.
U = rand(m,n)<=p; % U is true with probability p and false with probability 1-p
R = U.*gamrnd(a,b,m,n)+(1-U).*lognrnd(mu,sigma,m,n);
R should have the desired distribution.
0 Commenti
Più risposte (1)
Image Analyst
il 6 Ott 2013
Calculate the CDF and then get a random number from the uniform distribution and plug it in. See the method described here: http://en.wikipedia.org/wiki/Inverse_transform_sampling I've also attached my program for doing it with a rayleigh distribution. Click on the filename below (not the picture, but the filename).
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!