Category: functors | Component type: concept |
Argument type | The type of the Random Number Generator's argument. This must be an integral type. |
Result type | The type returned when the Random Number Generator is called. It must be the same as the argument type. |
F | A type that is a model of Random Number Generator. |
Integer | The argument type of F. |
f | Object of type F. |
N | Object of type Integer |
The range of a Random Number Generator is the set of nonnegative integers that are less than the Random Number Generator's argument.
Name | Expression | Precondition | Semantics | Postcondition |
---|---|---|---|---|
Function call | f(N) | N is positive. | Returns a pseudo-random number of type Integer. [2] | The return value is less than N, and greater than or equal to 0. |
Uniformity | In the limit as f is called many times with the same argument N, every integer in the range [0, N) will appear an equal number of times. |
[1] Uniform distribution means that all of the numbers in the range [0, N) appear with equal frequency. Or, to put it differently, the probability for obtaining any particular value is 1/N.
[2] Random number generators are a very subtle subject: a good random number generator must satisfy many statistical properties beyond uniform distribution. See section 3.4 of Knuth for a discussion of what it means for a sequence to be random, and section 3.2 for several algorithms that may be used to write random number generators. (D. E. Knuth, The Art of Computer Programming. Volume 2: Seminumerical Algorithms, third edition. Addison-Wesley, 1998.)
Contact Us | Site Map | Trademarks | Privacy | Using this site means you accept its Terms of Use |
Copyright © 2009 - 2014 Silicon Graphics International. All rights reserved. |