

In many cases, you can quantify the accuracy of a Monte Carlo study that simulates N independent samples. Taking that recommendation it's logical conclusion leads to Monte Carlo simulation in which you generate many (maybe 10,000 or 100,000) samples. See the posts "How to lie with a simulation" and "Monte Carlo estimates of pi and an important statistical lesson." I've written about how basing a conclusion on a single "unlucky" seed can lead to wrong conclusions. I always recommend that programmers change the seed a few times and make sure the results are similar and consistent.

Using one random sample is the same as basing a conclusion on a single sample of data, and we know that sampling variability means that we will reject a true null hypothesis (commit a Type 1 error) by chance 5% of the time.įortunately, with simulation we don't need to rely on one random sample. Do you now feel more confident that Project 9 is not affected by an "unusual" stream? I don't. Suppose you pick a different seed for Project 9. That means you can use %PUT to display the seed that SAS created, as follows: SAS puts the seed value into the SYSRANDOM system macro variable.

If you call the STREAMINIT subroutine with the value 0, then SAS will use the date, time of day, and possibly other information to manufacture a seed when you call the RAND function.

If you absolutely insist on using a "random seed," SAS can help. The relevant question for many SAS programmers is "can I use 12345 or my telephone number as seed values, or do I always need to type a crazy-looking nine-digit sequence?" My response is that there is no reason to prefer the crazy-looking seed over an easy-to-type sequence such as your phone number, your birthday, or the first few digits of pi. These are hard problems, but fortunately researchers have developed ways to initialize a stream from a seed so that there is a high probability that the stream will have excellent statistical properties.
BEST RANDOM NUMBER GENERATOR ALGORITHM HOW TO
There have been many discussions about how to create a seed initialization algorithm that is easy to call and that almost always results in a high-quality stream of random numbers. There have been cases where a RNG was published and the authors later modified the initialization routine because certain seeds did not result in streams that were sufficiently random. There have been many research papers written about how to take a 32-bit integer and use that information to initialize a RNG whose internal state contains more than 32 bits. Researchers who specialize in random number generators might criticize what I've said as overly simplistic. Initialization: Hard for researchers, easy for users Furthermore, many RNGs use the base-2 representation of the seed for initialization and (12345) 10 = (11000000111001) 2 looks pretty random! In fact, if you avoid powers of 2, the base-2 representations of most base-10 numbers "look random." In modern pseudorandom generators, the streams for different seeds should have similar statistical properties. They then assume that the random number stream that follows from CALL STREAMINIT(937162211) is "more random" than the random number stream for CALL STREAMINIT(12345). Some people see the number 937162211 and think that it looks "more random" than 12345. The stream for seed=12345 is just as random as the stream for the nine-digit prime number 937162211. However, there is no intrinsic reason to prefer one stream over another. When you specify a seed, SAS generates the same set of pseudorandom numbers every time you run the program. If you are still using the old-style RANUNI or RANNOR functions in SAS, please read the article "Six reasons you should stop using the RANUNI function to generate random numbers."Ī seed value specifies a particular stream from a set of possible random number streams. For example, in SAS you can use the STREAMINIT subroutine to initialize the Mersenne twister algorithm that is used by the RAND function. To be clear, I am talking about using a seed value to initialize a modern, high-quality, pseudorandom number generator (RNG). Each seed of a well-designed random number generator is likely to give rise to a stream of random numbers, so you can view the various streams as statistically equivalent. Last week I was asked a simple question: "How do I choose a seed for the random number functions in SAS?" The answer might surprise you: use any seed you like.
