Metropolis-Hastings sample
Afficher commentaires plus anciens
Hi,
I am trying to use "mhsample" command; make some samples by the MH algorithm. However, I am having a hard time dealing with "proppdf" and "proprnd", especially "proprnd". How can I find a criteria or solution to chose a good proposal pdf and its generator. For example, if I omit the "sum" of the first example of MATLAB HELP (for mhsample), I get second order moment about 4 instead of 8 (the code is in the following)! Why! what the generator essentially do?! Any help would be appreciated.
Thanks.
alpha = 2.43;
beta = 1;
pdf = @(x)gampdf(x,alpha,beta); %target distribution
proppdf = @(x,y)gampdf(x,floor(alpha),floor(alpha)/alpha);
proprnd = @(x)exprnd(floor(alpha)/alpha,1,1);
nsamples = 5000;
smpl = mhsample(1,nsamples,'pdf',pdf,'proprnd',proprnd,'proppdf',proppdf);
xxhat = cumsum(smpl.^2)./(1:nsamples)';
plot(1:nsamples,xxhat)
Réponses (0)
Catégories
En savoir plus sur Pseudorandom and Quasirandom Number Generation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!