g05kk allows for the generation of multiple, independent, sequences of pseudorandom numbers using the skip-ahead method. The base pseudorandom number sequence defined by state is advanced 2n places.


public static void g05kk(
	int n,
	G05..::..G05State g05state,
	out int ifail
Visual Basic
Public Shared Sub g05kk ( _
	n As Integer, _
	g05state As G05..::..G05State, _
	<OutAttribute> ByRef ifail As Integer _
Visual C++
static void g05kk(
	int n, 
	G05..::..G05State^ g05state, 
	[OutAttribute] int% ifail
static member g05kk : 
        n : int * 
        g05state : G05..::..G05State * 
        ifail : int byref -> unit 


Type: System..::..Int32
On entry: n, where the number of places to skip-ahead is defined as 2n.
Constraint: n0.
Type: NagLibrary..::..G05..::..G05State
An Object of type G05.G05State.
Type: System..::..Int32%
On exit: ifail=0 unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).


g05kk adjusts a base generator to allow multiple, independent, sequences of pseudorandom numbers to be generated via the skip-ahead method (see the G05 class for details).
If, prior to calling g05kk the base generator defined by state would produce random numbers x1,x2,x3,, then after calling g05kk the generator will produce random numbers x2n+1,x2n+2,x2n+3,.
One of the initialization methods (G05KFF not in this release) (for a repeatable sequence if computed sequentially) or (G05KGF not in this release) (for a non-repeatable sequence) must be called prior to the first call to g05kk.
The skip-ahead algorithm can be used in conjunction with any of the six base generators discussed in the G05 class.


Haramoto H, Matsumoto M, Nishimura T, Panneton F and L'Ecuyer P (2008) Efficient jump ahead for F2-linear random number generators INFORMS J. on Computing 20(3) 385–390
Knuth D E (1981) The Art of Computer Programming (Volume 2) (2nd Edition) Addison–Wesley

Error Indicators and Warnings

Errors or warnings detected by the method:
On entry,n<0.
On entry,state vector was not initialized or has been corrupted.
On entry, cannot use the skip-ahead method with the base generator defined by state.
On entry, the base generator is Mersenne Twister, but the state vector defined on initialization is not large enough to perform a skip-ahead. See the initialization method (G05KFF not in this release) (G05KGF not in this release).
An error occured, see message report.
Negative dimension for array value
Invalid Parameters value


Not applicable.

Parallelism and Performance


Further Comments

Calling g05kk and then generating a series of uniform values using g05sa is equivalent to, but more efficient than, calling g05sa and discarding the first 2n values. This may not be the case for distributions other than the uniform, as some distributional generators require more than one uniform variate to generate a single draw from the required distribution.


See Also