Skip-Ahead Method - 5.2 English - 68552

AOCL API Guide (68552)

Document ID
68552
Release Date
2025-12-29
Version
5.2 English

This is also known as Block-splitting method. Independent sequences of variates can be generated from a single base generator through the use of skipping-ahead or block-splitting. This method consists of splitting the sequence into k non-overlapping blocks, each of length n, where n is larger than the maximum number of variates required from any of the sequences. For example:

\[\frac{x_1,x_2, \dotsi,x_n}{block 1} \frac{x_{n+1},x_{n+2}, \dotsi,x_{2n}}{block 2} \frac{x_{2n+1},x_{2n+2}, \dotsi,x_{3n}}{block 3},\ etc\]

where \(x_1, x_2\), is the sequence produced by the generator of interest. Each of the k blocks provide an independent sequence.

The skipping-ahead algorithm therefore requires the sequence to be advanced a large number of places. Due to their form this can be done efficiently for LCG and MCG. AOCL-RNG library provides skipping-ahead for the NAG Basic generator, the Wichmann-Hill generators and MRG32K3A generator.

C Generate 3 * 100 values from the Uniform distribution
C Multiple streams generated using the Skip Ahead method
    INTEGER LSTATE,N
    PARAMETER (LSTATE=16,N=100)
    INTEGER I,INFO,NSKIP
    INTEGER SEED(1),STATE1(LSTATE),STATE2(LSTATE),STATE3(LSTATE)
    DOUBLE PRECISION X1(N),X2(N),X3(N)
    DOUBLE PRECISION A,B

C Set the seed
    SEED(1) = 1234

C Set the distributional parameters
    A = 0.0D0
    B = 1.0D0

C Initialize the STATE1 vector
    CALL DRANDINITIALIZE(1,1,SEED,1,STATE1,LSTATE,INFO)

C Copy the STATE1 vector into other state vectors
    DO 20 I = 1,LSTATE
      STATE2(I) = STATE1(I)
      STATE3(I) = STATE1(I)
20  CONTINUE

C Calculate how many places we want to skip, this
C should be >> than the number of variates we
C wish to generate from each stream
    NSKIP = N * N

C Advance each stream, first does not need changing
    CALL DRANDSKIPAHEAD(NSKIP,STATE2,INFO)
    CALL DRANDSKIPAHEAD(2*NSKIP,STATE3,INFO)

C Generate 3 sets of N variates from the Univariate distribution
    CALL DRANDUNIFORM(N,A,B,STATE1,X1,LDX,INFO)
    CALL DRANDUNIFORM(N,A,B,STATE2,X2,LDX,INFO)
    CALL DRANDUNIFORM(N,A,B,STATE3,X3,LDX,INFO)

C Print the results
    DO 40 I = 1,N
      WRITE(6,*) X1(I),X2(I),X3(I)
40  CONTINUE