Skip to content

GetSeed

Description

GetSeed returns an integer that can be used as a seed into a random number generator (RNG). This is a volatile function which means that any RNG function that uses it to generate a seed will be volatile.

Syntax

This function has no input parameters, so =GetSeed() will return a (volatile) RNG seed. Commonly this function would be used as an input into one of the other CLS-Stats RNG functions to make it volatile, at least temporarily.

If you want a function to be permanently volatile then you might want to consider using Excel’s RNGs for your simulation since they are a little faster and more randomized than the CLS-Stats version.

Example

Two common use cases for this function:

  • use =GetSeed() in a separate cell and refer to that cell for the seed in one of the CLS-Stats RNGs
  • use GetSeed() in the call to one of the CLS-Stats RNGs

Both cases are illustrated below and in the attached Excel file. You can see the volatile cells change by hitting the F9 key or making most any other change to the spreadsheet. (Formatting changes do not trigger a recalc but other changes do.)

GetSeed returns a volatile seed; runif seeded from it changes on every recalculation, while plain runif(10) does not

Download: GetSeed.xlsx

Source Code

As you can see, GetSeed is a thin wrapper for RANDBETWEEN.

GetSeed = LAMBDA(
    RANDBETWEEN(1,2^31 - 1)
);