g05kh allows for the generation of multiple, independent, sequences of pseudorandom numbers using the leap-frog method.

# Syntax

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

#### Parameters

n
Type: System..::..Int32
On entry: $n$, the total number of sequences required.
Constraint: ${\mathbf{n}}>0$.
k
Type: System..::..Int32
On entry: $k$, the number of the current sequence.
Constraint: $0<{\mathbf{k}}\le {\mathbf{n}}$.
g05state
Type: NagLibrary..::..G05..::..G05State
An Object of type G05.G05State.
ifail
Type: System..::..Int32%
On exit: ${\mathbf{ifail}}={0}$ unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

# Description

g05kh adjusts a base generator to allow multiple, independent, sequences of pseudorandom numbers to be generated via the leap-frog method (see the G05 class for details).
If, prior to calling g05kh the base generator defined by state would produce random numbers ${x}_{1},{x}_{2},{x}_{3},\dots$, then after calling g05kh the generator will produce random numbers ${x}_{k},{x}_{k+n},{x}_{k+2n},{x}_{k+3n},\dots$.
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 g05kh.
The leap-frog algorithm can be used in conjunction with the NAG basic generator, both the Wichmann–Hill I and Wichmann–Hill II generators, the Mersenne Twister and L'Ecuyer.

# References

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:
${\mathbf{ifail}}=1$
 On entry, ${\mathbf{n}}\le 0$.
${\mathbf{ifail}}=2$
 On entry, ${\mathbf{k}}>{\mathbf{n}}$.
${\mathbf{ifail}}=3$
 On entry, state vector was not initialized or has been corrupted.
${\mathbf{ifail}}=4$
On entry, cannot use the leap-frog method with the base generator defined by state.
${\mathbf{ifail}}=-9000$
An error occured, see message report.
${\mathbf{ifail}}=-8000$
Negative dimension for array $〈\mathit{\text{value}}〉$
${\mathbf{ifail}}=-6000$
Invalid Parameters $〈\mathit{\text{value}}〉$

Not applicable.

None.