g05td generates a vector of pseudorandom integers from a discrete distribution with a given PDF (probability density function) or CDF (cumulative distribution function) .
public static void g05td( mode, n,  p, np, ip1, itype,  r, G05..::.G05State g05state,  x, out ifail )
|Visual Basic (Declaration)|
Public Shared Sub g05td ( _ mode As , _ n As , _ p As (), _ np As , _ ip1 As , _ itype As , _ r As (), _ g05state As G05..::.G05State, _ x As (), _ < > ByRef ifail As _ )
public: static void g05td( mode, n, array< >^ p, np, ip1, itype, array< >^ r, G05..::.G05State^ g05state, array< >^ x, [ ] % ifail )
static member g05td : mode: * n: * p:  * np: * ip1: * itype: * r:  * g05state:G05..::.G05State * x:  * ifail: byref -> unit
On entry: a code for selecting the operation to be performed by the method.
Constraint: , or .
- Set up reference vector only.
- Generate variates using reference vector set up in a prior call to g05td.
- Set up reference vector and generate variates.
On entry: , the number of pseudorandom numbers to be generated.Constraint: .
- Type: array<
>()An array of size [np]On entry: the PDF or CDF of the distribution.Constraints:
- , for ;
- if , ;
- if , .
On entry: the number of values supplied in p defining the PDF or CDF of the discrete distribution.Constraint: .
On entry: the value of the variate, a whole number, to which the probability in corresponds.
On entry: indicates the type of information contained in p.Constraint: or .
- Type: array<
>()An array of size [lr]Note: lr must satisfy the constraint:On entry: if , the reference vector from the previous call to g05td.On exit: the reference vector.
- Type: array<
>()An array of size [n]On exit: contains pseudorandom numbers from the specified discrete distribution.
On exit: unless the method detects an error (see [Error Indicators and Warnings]).
g05td generates a sequence of integers , from a discrete distribution defined by information supplied in p. This may either be the PDF or CDF of the distribution. A reference vector is first set up to contain the CDF of the distribution in its higher elements, followed by an index.
Setting up the reference vector and subsequent generation of variates can each be performed by separate calls to g05td or may be combined in a single call.
Errors or warnings detected by the method:
Some error messages may refer to parameters that are dropped from this interface (lr, lstate) In these cases, an error in another parameter has usually caused an incorrect value to be inferred.
With , for at least one value of .With , the sum of , for , does not equal .With , the values of are not all in non-descending order.
The value of np, itype or ip1 is not the same as when r was set up in a previous call to g05td with or .On entry, the r vector was not initialized correctly, or has been corrupted.
On entry, g05state vector was not initialized or has been corrupted.
This example prints pseudorandom variates from a discrete distribution whose PDF, , is defined as follows:
The reference vector is set up and and the variates are generated by a single call to g05td, after initialization by the state constructor (for a repeatable sequence).