Why am I unable to reproduce the random numbers generated by the GAMRND function in the Statistics Toolbox?
2 views (last 30 days)
Show older comments
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.
Accepted Answer
MathWorks Support Team
on 27 Jun 2009
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)
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!