NTRAND
Returns uniform pseudo random number(s) in (0, 1) based on Mersenne Twister Algorithm which has long period (), high order of equidistribution and 623 dimensions.
Syntax
NTRAND(
Size,
Algorithm,
Random seed1,
Random seed2
)
Parameters
- Size is # of random numbers (Positive integer).
- Algorithm is an integer value that determines a method to generate uniform random number.
- 0: Mersenne Twister(2002)
- 1: Mersenne Twister(1998)
- 2: Numerical Recipes ran2()
- Random seed1 is 1st. random seed.
- Random seed2 is 2nd. random seed.
Remarks
- More precisely, a range of random number is
- To generate uniform random numbers between a and b (a < b), use:
=(b-a)*NTRAND(100)+a
- To generate discrete random numbers in [m, n] (m and n are integer and m < n), use:
=INT(NTRAND(100)*(n-m+1))+m
For example, to model a dice (output is in [1,6]):
=INT(NTRAND(100)*6)+1
Example
How to copy an example
-
Create a blank workbook or worksheet.
-
Select the example in the Help topic.
Note Do not select the row or column headers.
Selecting an example from Help
-
Press CTRL+C.
-
In the worksheet, select cell A1, and press CTRL+V.
-
To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Tools menu, point to Formula Auditing, and then click Formula Auditing Mode.
A | B | |
---|---|---|
1 | Data | Description |
2 | =NTRAND(100,0,12345,67890) | 100 uniform random numbers by Mersenne Twister algorithm with random seeds 12345 and 67890 |
Note : The formula in the example must be entered as an array formula. After copying the example to a blank worksheet, select the range A2:A101 starting with the formula cell. Press F2, and then press CTRL+SHIFT+ENTER.