RANDOM NUMBER GENERATION
2.5.3 STATE SPACE PARTITION
Provided (a, m) are properly chosen, Lehmer generators: (1) have full period, (2) have been extensively studied, (3) provide multiple streams, and (4) produce output that is generally considered to be acceptably random for discrete-event simulation purposes.
Given all of that, one could ask why anyone would be interested in other types of generators, particularly if they are not full-period generators. But, the discussion in this section is not focused on random number generators exclusively, and certainly not on Lehmer generators.
Instead, the focus is on general state transition functions and corresponding finite-state sequences that may not be (and generally will not be) full period. Correspondingly, in the remainder of this section we will study a state space partition that is naturally associated with state transition functions that are not full period. The study of this state space partition is facilitated by introducing the idea of “jump” functions, defined as follows.
Jump Functions
If g : X → X then for all x ∈ X inductively define the jump function gj(x) as follows
gj(x) =½ x j = 0
g¡gj−1(x)¢
j = 1, 2, 3, . . .
Because g : X → X it follows that gj : X → X for any j ≥ 0. That is, the jump function gj(·) is also a state transition function. Moreover, if g(·) generates the sequence x0, x1, x2, x3, . . .then gj(·) generates the sequence x0, xj, x2j, x3j, . . . In terms of the race-track analogy, if j ≥ 2 then the state transition function gj(·) runs the race j times faster than g(·) by jumping ahead j states at a time. This important idea is used in Chapter 3 to construct a Lehmer random number generator that can create and maintain multiple streams of random numbers.
Periodic and Transient States
The following definition is the key to studying the state space partition that is natu-rally associated with a state transition function that is not full period.
Definition 2.5.4 Given a finite state space X and state transition function g : X → X , then x ∈ X is a periodic (or recurrent) state if and only if there exists a positive integer j with 0 < j ≤ |X | such that gj(x) = x. If x ∈ X is not a periodic state, then it is said to be a transient state.
Theorem 2.5.1 is the basis for this definition. If x = x0 is the initial state in a finite-state sequence, then either s = 0 in which case x is a periodic finite-state because gp(x) = x, or s >0 in which case x is a transient state because gj(x) 6= x for all j = 1, 2, . . .
Definition 2.5.5 If x ∈ X is a periodic state, then the recurrent class corresponding to x is the set
R= {gi(x) : i = 0, 1, 2, . . . , j − 1}
where j is the smallest positive integer such that gj(x) = x. Note that |R| = j.
From Theorem 2.5.1, there must be at least one periodic state. Therefore, there must be at least one recurrent class. Moreover, if x ∈ X is a periodic state with corresponding recurrent class R and if x0 ∈ X is a periodic state with corresponding recurrent class R0, then either R = R0 or R ∩ R0 = ∅. That is, the set of periodic states is partitioned into recurrent classes. Equivalently, as Examples 2.5.6 and 2.6.7 illustrate, if there are multiple recurrent classes then the classes are disjoint — each periodic state belongs to exactly one recurrent class.
For reference, note that if g(·) is a full-period state transition function then all states are periodic and there is only one recurrent class, which is X . If g(·) is not a full-period state transition function then, generally, there will be transient states and more than one recurrent class, but not necessarily.
Example 2.5.6 The 1-digit midsquares state transition function g(x) = bx2cmod 10 = x2 mod 10
has four periodic states (0, 1, 5, 6) and four transient states (2, 3, 4, 7, 8, 9). The periodic states are partitioned into four recurrent classes: {0}, {1}, {5}, and {6}, as illustrated in Figure 2.5.1.
Example 2.5.7 For the 4-digit midsquares state transition function, it can be shown that there are 17 periodic states and 9983 transient states. The periodic states are par-titioned into eight recurrent classes: {2100, 4100, 8100, 6100}, {0}, {100}, {2500}, {7600}, {1600, 5600, 3600, 9600}, {540, 2916, 5030, 3009}, and {3792}.
Although the recurrent classes contain periodic states only, from Theorem 2.5.1 any transient state x ∈ X is “connected to” a recurrent class in the sense that there is a positive integer j such that gj(x) is a periodic state. This observation is summarized by the following theorem.
Theorem 2.5.5 If x ∈ X is a transient state then there then there exists a unique recurrent class R such that gj(x) ∈ R for some j with 0 < j < |X |. In this case x is said to be connected to R.
It follows from Theorem 2.5.5 that each recurrent class has associated with it a (per-haps empty) set of transient states that are connected to it. In this way, each recurrent class can be naturally enlarged to an associated “cluster”.
Definition 2.5.6 For each recurrent class R, the associated recurrent class cluster is C = R ∪ {all the transient states that are connected to R}.
There is one cluster for each recurrent class, the clusters are disjoint, and each state (transient or periodic) is in exactly one cluster. Equivalently, the clusters partition the state space. This is an important conceptual result, particularly as it relates to understanding the behavior of bad random number generators.
Relative to the conceptual model that random number generation corresponds to drawing at random from an urn, the clusters correspond to urns, the initial state of the generator determines the urn (cluster) from which all subsequent draws will be made, and the recurrent class in the cluster defines the periodic cycle into which the output of the generator must ultimately collapse. If the initial state of the generator is selected at random, the cardinality of each cluster determines the probability that cluster (urn) will be selected.
Example 2.5.8 As a continuation of Example 2.5.7, for the 4-digit midsquares state transition function, there are eight clusters. The recurrent class associated with each cluster is illustrated in the table below, along with the size of each cluster. The table is sorted by decreasing cluster size
cluster size recurrent class 6291 {2100, 4100, 8100, 6100}
1968 {0}
1360 {1600, 5600, 3600, 9600}
130 {2500}
104 {100}
86 {540, 2916, 5030, 3009}
60 {7600}
1 {3792}
As a source of random numbers, the 4-digit midsquares method is a non-starter.
It is an interesting exercise to construct a time efficient algorithm that will generate the state space decomposition into recurrent class clusters. In that regard, see Exercise 2.5.4.
2.5.4 EXERCISES
Exercise 2.5.1 The BASICA random number generator for the original “true blue”
IBM PC was defined by the state transition function
g(x) = (a(x mod 216) + c) mod 224
with a = 214 013 and c = 13 523 655. (a) If g : X → X with X = {0, 1, . . . , m − 1} what is m? (b) Determine (s, p) for initial seeds of 0, 1, 12, 123, 1234, and the last four digits of your social security number. (c) For each initial seed, how does |X | = m relate to p?
(d) Comment.
Exercise 2.5.2 Determine (s, p) for both of the following state transition functions
long g(long x) /* start with x = 777 */
{
x = (123 * x + 1) % 123456;
return x;
}
long g(long x) /* start with x = 37911 and x = 1 */
{
x = (9806 * x + 1) % 131071;
return x;
}
Exercise 2.5.3 Prove or disprove the following two conjectures. Given that |X | is finite, g: X → X , x0 ∈ X, and (s, p) are the values returned by Algorithm 2.5.3: (a) if s = 0 and p= |X | then the function g is a bijection (one-to-one and onto); (b) if the function g is a bijection then s = 0 and p = |X |.
Exercise 2.5.4a Given a finite state space X and state transition function g : X → X , construct an efficient algorithm that partitions the state space into clusters. In particular, the algorithm should output the size (cardinality) of each cluster, the smallest periodic state in each cluster, and the size of each associated recurrent class. (a) What is the output of this algorithm when applied to the 6-digit midsquares state transition function?
(b) Same question for the state transition function in Exercise 2.5.1? (c) Comment on both of these state transition functions as a possible source of random numbers. (d) What is the time complexity (relative to g(·) evaluations) and space complexity of your algorithm?
Exercise 2.5.5a Consider a large round 12-hour clock with an hour hand, a minute hand, and 3600 marks (seconds) around the circumference of the clock. Both hands move in discrete steps from one mark to the next. The marks define the set X = {0, 1, . . . , 3599}.
Assume that both hands are “geared” so that a manual movement of the hour hand by one mark forces the minute hand to move by 12 marks. Generate a sequence of integers x0, x1, x2, . . .in X as follows. Start with the hands in an arbitrary location (time) and let x0 ∈ X be the location (mark) of the minute hand. To generate x1, move the hour hand clockwise to the minute hand mark (x0), allowing the minutes hand to spin accordingly to a new mark; this new minute hand mark is x1 ∈ X. To generate x2, move the hour hand to x1 and let x2 ∈ X be the new location of the minute hand, etc. What do you think of this as a source of random numbers? (“Not much” is not a sufficient answer.)
Exercise 2.5.6a Same as Exercise 2.5.5 except for a clock with 360 000 marks around the circumference.
As discussed in Chapter 1, ssq1 and sis1 are examples of trace-driven discrete-event simulation programs. By definition, a trace-driven simulation relies on input data from an external source to supply recorded realizations of naturally occurring stochastic processes. Total reliance on such external data limits the applicability of a discrete-event simulation program, naturally inhibiting the user’s ability to do “what if” studies. Given this limitation, a general discrete-event simulation objective is to develop methods for using a random number generator to convert a trace-driven discrete-event simulation program to a discrete-event simulation program that is not dependent on external data. This chapter provides several examples.