Gamma distribution & Markov chain Monte Carlo



Hi guys,

I code a small piece to generate variates from Gamma distribution with
Markov chain Monte Carlo as shown below. The appeared results,
however, using 'hist(vari)' command does not looks like it follows
Gamma distribution at all. (I compare it with 'gamrnd' provided in
Matlab.) None of Metropolis - Hastings or Metropolis method works.
Please kindly provide me some hints about this problem, I'm totally
lost.

Thanks in advance. Any comment is highly appreciated.
Iaoh.

--------------------

clear all

% number of iterations
n = 5000;
% burn-in rounds
burnin = 2000;
% preallocate the array
vari = zeros(1, n);

str = 'x^(a - 1)*exp(-b*x)'; % gamma distribution
gamDist = inline(str, 'x', 'a', 'b');
a = 1;
b = 1;

str = 'exp(-0.5*((x-mu)/sig)^2)';
norm = inline(str, 'x', 'mu', 'sig');
sig = 1;

vari(1) = randn(1); % initial value
for index = 2:n
% normal distribution is used as proposal distribution
y = vari(index - 1) + randn(1)*sig;
% draw u from normal distribution
u = randn(1);
% calculate accepting factor alpha
% by Metropolis - Hastings method
alpha = min(1, (gamDist(y, a, b))*norm(vari(index - 1), y,
sig)/...
((gamDist(vari(index - 1), a, b))*norm(y, vari(index -
1), sig)));
% by Metropolis-only method
% alpha = min(1, (gamDist(y, a, b))/(gamDist(vari(index - 1), a,
b)));
if u <= alpha
vari(index) = y;
else
vari(index) = vari(index - 1);
end
end

% remove burn-in elements
vari = vari(burnin:n);
hist(vari);
.



Relevant Pages

  • Gamma distribution & Markov chain Monte Carlo
    ... Gamma distribution at all. ... None of Metropolis - Hastings or Metropolis method works. ... % calculate accepting factor alpha ...
    (comp.soft-sys.matlab)
  • Re: Monte Carlo II
    ... distribution this gives sometimes values ... symmetrical, then alpha equals beta. ... limits -3,+3 and multiply that ...
    (sci.stat.math)
  • Special Functions Revisited By PI
    ... forums developing relationships between PI and "Special Functions", ... the gamma distribution in probability-statistics, ... probably the main example of how PI goes beyond Shannon entropy ...
    (sci.stat.math)
  • Re: Gamma Distribution Question
    ... it follows a Gamma distribution better than a normal ... What relation does it have to Poisson processes? ... the nth-order interarrival time in a Poisson process has gamma distribution. ... But it looks like you are considering the *number* of harvests per month, ...
    (sci.stat.math)
  • Re: normal distribution with uncertain mean and standard deviation
    ... distribution for the variance parameter, ... However, while there's a connection to Bayesian calculations, ... variance parameter had a gamma distribution I think the result would ...
    (sci.stat.math)

Loading