'How to set a seed for the generating random numbers in Excel? [duplicate]
I am running a experiment in excel using NORM.S.INV(RAND())
Is there a way to set the seed for the random function?
Solution 1:[1]
I found I needed persisted random numbers all the time. Turns out this is possible using only standard spreadsheet formulas.
One way is to use the so called Lehmer random number method. It generates a sequence of random numbers in your spreadsheet that stays the same until you change the "seed number", a number you choose yourself and will recreate a different random sequence for each seed number you choose.
The short version:
- In cell B1, enter your "seed" number, it can be any number from 1 to 2,147,483,647
- In cell B2 enter the formula
=MOD(48271*B1,2^31-1)
, this will generate the first random number of your sequence. - Now copy this cell down as far as the the random sequence you want to generate.
That's it! If you want a different set of numbers, just change the seed number in B1. If you ever want to recreate the same set of numbers again, just use the same seed and the same random sequence will appear.
More details in this tutorial: How to generate random numbers that don't change in Excel and Google Sheets
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |