A Question about the new Prior Sampler

Is there a typo around the area to use gamrnd or betarnd to draw values? The two matlab functions gamrnd and betarnd only accept scalar as input, but the generated gamma_index or beta_index are vectors.

Hi, Please correct me if I am wrong… The matlab stat toolbox is able to draw vectors (even matrices) of independent gamma or beta variates. What is the version of your statistical toolbox ?

I wrote an m file (also called gamrnd.m) to draw vectors of independent gamma variates. This file is located under /matlab/distributions/toolbox and this folder is written in the matlab’s path by dynare if the stat toolbox is not detected.


Hi, I haven’t tried the gamrnd used in matlab stat toolbox. What I am talking about is the gamrnd in Dynare 4.02. It doesn’t take vectors as input. Below is what I get:

??? Error using ==> gamrnd at 31
gamrnd: A and B should be scalar parameters.

OK. The new prior sampler is in the trunk directory of our subversion repository (the future version 4.1 of dynare). The gamrnd function shipped with dynare 4.0.2 does not handle vector of gamma distributed draws but the new version (in the trunk) does.

The new version of gamrnd is also more general because, it can produce more efficiently random deviates when the parameter a is small (less than 1, in this case the gamma distribution is monotone decreasing and has an asymptote at zero). Also with the new version it is possible to simulate draws from the beta, when parameters a and b are such that the beta density has asymptotes at 0 and/or 1.

Best, Stéphane.