MATLAB: Am I unable to reproduce the random numbers generated by the GAMRND function in the Statistics Toolbox

gammajgrandMATLABrngstateStatistics and Machine Learning Toolbox

I set the state of RAND before calling GAMRND. However the output is not reproduced. Below is a function that illustrates the issue:
function testgamma
state = 0
rand('state', state);
n1 = gamrnd(1,1)
Calling "testgamma.m" repeatedly does not result in the same set of random numbers generated.

Best Answer

This change has been incorporated into the documentation in Release 14 Service Pack 3 (R14SP3). For previous releases, read below for any additional information:
We have verified that the documentation for reproducing outputs of random number generator functions in the Statistics Toolbox is incomplete.
To reproduce the output of GAMRND, you need to set the state of both RAND and RANDN. Below is an example to illustrate this:
state = 0
rand('state', state);
randn('state', state);
n1 = gamrnd(1,1)