HomeTechniques and Tips@RISK Simulation: Numerical ResultsWhat Was My Random Number Seed?

6.8. What Was My Random Number Seed?

Applies to: @RISK 5.x–7.x

I've run a simulation, but it was with the random number seed set to "Choose Randomly". How can I find out what seed @RISK actually used, so that I can reproduce the simulation later?

If Quick Reports were run automatically at the end of the simulation, look at the Simulation Summary Information block on any of them. The RandomSeed item gives you the random number seed that was actually used. If you haven't run Quick Reports, you can do that without re-running the simulation: click Excel Reports and tick Quick Reports.

If you don't have any outputs, or if you have a lot of them and don't want to run Quick Reports, you can use a snippet of Visual Basic code without being a programmer:

  1. Press Alt-F11 to open the Visual Basic Editor, then F7 to open the code window.

  2. Paste this VBA code into the window:

    Sub StoreSeed()
        Risk.Simulation.Settings.RandomSeed = _
            Risk.Simulation.Results.RandomNumberSeed
    End Sub
  3. Please see Setting References in Visual Basic for the necessary references and how to set them.

  4. Click somewhere in the middle of the StoreSeed routine, and press F5 to run the code. This will change @RISK's Simulation Settings, on the Sampling tab, to a fixed random seed. and it will insert the actual seed from the latest simulation as the seed for future simulations.

  5. If you leave the code in place, Excel 2007 or above will no longer store the workbook as an .XLSX but instead will use .XLSM format. This may present you or anyone who opens your workbook with a macro security prompt. To prevent that, you can delete the pasted code before you save the workbook. The fixed random seed will remain in Simulation Settings.

  6. Save the workbook to save the fixed random seed.

See also: Random Number Generation, Seed Values, and Reproducibility

Last edited: 2014-06-26

This page was: Helpful | Not Helpful