nag_rngs_init_repeatable (g05kbc) (PDF version)
g05 Chapter Contents
g05 Chapter Introduction
NAG C Library Manual

NAG Library Function Document

nag_rngs_init_repeatable (g05kbc)

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

nag_rngs_init_repeatable (g05kbc) sets the initial seeds for the selected generator as used by and passed to the group of pseudorandom number functions g05k–g05q.

2  Specification

#include <nag.h>
#include <nagg05.h>
void  nag_rngs_init_repeatable (Integer *igen, Integer iseed[])

3  Description

nag_rngs_init_repeatable (g05kbc) sets the seeds used by the selected generator mechanism (see the g05 Chapter Introduction) to values calculated from the argument array iseed. The pseudorandom number generator is selected by the input value of the argument igen.
For the same value of igen, this function will yield different subsequent sequences of random numbers if called with different values of iseed, but the sequences, if calculated sequentially, will be repeatable in different runs of the calling program. It should be noted that there is no guarantee of statistical properties between sequences, only within sequences.

4  References

None.

5  Arguments

1:     igenInteger *Input/Output
On entry: must contain the identification number for the generator to be used to return a pseudorandom number and should remain unchanged until a re-initialization by a call to one of the functions nag_rngs_init_repeatable (g05kbc) or nag_rngs_init_nonrepeatable (g05kcc). The values that may be chosen are:
  • igen=0, the basic generator;
  • 1igen273, a Wichman–Hill generator.
See the g05 Chapter Introduction for details.
On exit: if igen<0 on input then igen is set to 0, if igen>273 on input then igen is set to igen-1 mod 273+1.
2:     iseed[4]IntegerCommunication Array
On entry: must contain values which are used to obtain an initial state for the generator selected by the argument igen. The treatment of the array iseed differs depending on the value of igen input. As a result, the requirements for meaningful values of the elements of iseed also depend on igen; these requirements are as follows:
  • if igen=0, only iseed[0] need be set to any non-negative integer;
  • otherwise, all elements of iseed must be set and should be positive and are recommended to be at least five digits in length.
On exit: contains initial seeds for the selected generator.

6  Error Indicators and Warnings

None.

7  Accuracy

Not applicable.

8  Further Comments

None.

9  Example

This example prints the first five pseudorandom real numbers from a uniform distribution between 0 and 1, generated by nag_rngs_basic (g05kac) after initialization by nag_rngs_init_repeatable (g05kbc).

9.1  Program Text

Program Text (g05kbce.c)

9.2  Program Data

None.

9.3  Program Results

Program Results (g05kbce.r)


nag_rngs_init_repeatable (g05kbc) (PDF version)
g05 Chapter Contents
g05 Chapter Introduction
NAG C Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2012