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 StataLearn
Free webinars
NetCourses
Classroom and web training
Organizational training
Video tutorials
Third-party courses
Web resources
Teaching with Stata
© Copyright 1996–2025 StataCorp LLC. All rights reserved.
×
We use cookies to ensure that we give you the best experience on our website—to enhance site navigation, to analyze usage, and to assist in our marketing efforts. By continuing to use our site, you consent to the storing of cookies on your device and agree to delivery of content, including web fonts and JavaScript, from third party web services.
Cookie Settings
Last updated: 16 November 2022
StataCorp LLC (StataCorp) strives to provide our users with exceptional products and services. To do so, we must collect personal information from you. This information is necessary to conduct business with our existing and potential customers. We collect and use this information only where we may legally do so. This policy explains what personal information we collect, how we use it, and what rights you have to that information.
These cookies are essential for our website to function and do not store any personally identifiable information. These cookies cannot be disabled.
This website uses cookies to provide you with a better user experience. A cookie is a small piece of data our website stores on a site visitor's hard drive and accesses each time you visit so we can improve your access to our site, better understand how you use our site, and serve you content that may be of interest to you. For instance, we store a cookie when you log in to our shopping cart so that we can maintain your shopping cart should you not complete checkout. These cookies do not directly store your personal information, but they do support the ability to uniquely identify your internet browser and device.
Please note: Clearing your browser cookies at any time will undo preferences saved here. The option selected here will apply only to the device you are currently using.