**Overview**

I describe how to generate random numbers and discuss some features added in Stata 14. In particular, Stata 14 includes a new default random-number generator (RNG) called the Mersenne Twister (Matsumoto and Nishimura 1998), a new function that generates random integers, the ability to generate random numbers from an interval, and several new functions that generate random variates from nonuniform distributions.

**Random numbers from the uniform distribution**

In the example below, we use **runiform()** to create Read more…

For those interested in **how pseudo random number generators work**, I just wrote something on Statalist which you can see in the Statalist archives by clicking the link even if you do not subscribe:

**http://www.stata.com/statalist/archive/2012-10/msg01129.html**

To remind you, I’ve been writing about how to *use* random-number generators in parts **1**, **2**, and **3**, and I still have one more posting I want to write on the subject. What I just wrote on Statalist, however, is about how random-number generators work, and I think you will find it interesting.

To find out more about Statalist, see

**Statalist**

**How to successfully ask a question on Statalist**

The topic for today is drawing random samples with replacement. If you haven’t read part 1 and part 2 of this series on random numbers, do so. In the series we’ve discussed that Read more…

Last time I told you that Stata’s **runiform()** function generates rectangularly (uniformly) distributed random numbers over [0, 1), from 0 to nearly 1, and to be precise, over [0, 0.999999999767169356]. And I gave you two formulas,

- To generate
*continuous* random numbers between *a* and *b*, use
**generate double u =** **(***b***–***a***)*runiform() +** *a*

The random numbers will not actually be between *a* and *b*: they will be between *a* and nearly *b*, but the top will be so close to *b*, namely 0.999999999767169356**b*, that it will not matter.

- To generate
*integer* random numbers between *a* and *b*, use Read more…

I want to start a series on using Stata’s random-number function. Stata in fact has ten random-number functions: Read more…