g05tc Method
関数リスト一覧   NagLibrary Namespaceへ  ライブラリイントロダクション  本ヘルプドキュメントのchm形式版

g05tc generates a vector of pseudorandom integers from the discrete geometric distribution with probability p of success at a trial.


public static void g05tc(
	int mode,
	int n,
	double p,
	double[] r,
	G05..::.G05State g05state,
	int[] x,
	out int ifail
Visual Basic (Declaration)
Public Shared Sub g05tc ( _
	mode As Integer, _
	n As Integer, _
	p As Double, _
	r As Double(), _
	g05state As G05..::.G05State, _
	x As Integer(), _
	<OutAttribute> ByRef ifail As Integer _
Visual C++
static void g05tc(
	int mode, 
	int n, 
	double p, 
	array<double>^ r, 
	G05..::.G05State^ g05state, 
	array<int>^ x, 
	[OutAttribute] int% ifail
static member g05tc : 
        mode:int * 
        n:int * 
        p:float * 
        r:float[] * 
        g05state:G05..::.G05State * 
        x:int[] * 
        ifail:int byref -> unit 


Type: System..::.Int32
On entry: a code for selecting the operation to be performed by the method.
Set up reference vector only.
Generate variates using reference vector set up in a prior call to g05tc.
Set up reference vector and generate variates.
Generate variates without using the reference vector.
Constraint: mode=0, 1, 2 or 3.
Type: System..::.Int32
On entry: n, the number of pseudorandom numbers to be generated.
Constraint: n0.
Type: System..::.Double
On entry: the parameter p of the geometric distribution representing the probability of success at a single trial.
Constraint: machine precisionp1.0 (see x02aj).
Type: array< System..::.Double >[]()[]
An array of size [lr]
Note: lr must satisfy the constraint:
  • if mode=0 or 2, lr30/p+8;
  • if mode=1, lr should remain unchanged from the previous call to g05tc.
On entry: if mode=1, the reference vector from the previous call to g05tc.
If mode=3, r is not referenced by g05tc.
On exit: the reference vector.
Type: NagLibrary..::.G05..::.G05State
An object of type G05.G05State.
Type: array< System..::.Int32 >[]()[]
An array of size [n]
On exit: the n pseudorandom numbers from the specified geometric distribution.
Type: System..::.Int32 %
On exit: ifail=0 unless the method detects an error (see [Error Indicators and Warnings]).


g05tc generates n integers xi from a discrete geometric distribution, where the probability of xi=I (a first success after I trials) is
P xi=I = p × 1-p I-1 ,   I=1,2, .
The variates can be generated with or without using a search table and index. If a search table is used then it is stored with the index in a reference vector and subsequent calls to g05tc with the same parameter value can then use this reference vector to generate further variates. If the search table is not used (as recommended for small values of p) then a direct transformation of uniform variates is used.


Error Indicators and Warnings


Further Comments

The time taken to set up the reference vector, if used, increases with the length of array r. However, if the reference vector is used, the time taken to generate numbers decreases as the space allotted to the index part of r increases. Nevertheless, there is a point, depending on the distribution, where this improvement becomes very small and the suggested value for the length of array r is designed to approximate this point.
If p is very small then the storage requirements for the reference vector and the time taken to set up the reference vector becomes prohibitive. In this case it is recommended that the reference vector is not used. This is achieved by selecting mode=3.


See Also