Stata now uses the 64-bit Mersenne Twister (MT64) as its default random-number generator. Stata previously used the 32-bit KISS generator (KISS32), and still does under version control. KISS32 is an excellent random-number generator, but the Mersenne Twister has even better properties.
The MT64 is currently the most widely used random-number generator. It has a much larger period than the majority of random-number generators, meaning that you can run simulations of simulations of simulations without ever drawing the same random numbers. In addition, the MT64 generator requires 623 dimensions to exhibit patterns.
Suppose we wish to generate 1,000 observations from a Weibull(3,1) distribution. We first set the number of observations and then set the seed for reproducibility.
. set obs 1000 . set seed 2414830
We then generate our new variable. To see the results, we summarize it.
. generate weib_mt64 = rweibull(3,1) . summarize weib_mt64
|Variable||Obs Mean Std. Dev. Min Max|
|weib_mt64||1,000 .907414 .3235842 .1243035 1.930414|
For more information about the Mersenne Twister, see Methods and formulas.
To learn more about Stata's new random-number functions and the statistical distribution functions that accompany them, see Statistical distribution functions.
To find out more about all of Stata's Random-number functions, see the new 151-page Stata Functions Reference Manual.Upgrade now Order Stata