naginterfaces.library.rand.int_general¶
- naginterfaces.library.rand.int_general(mode, n, p, ip1, itype, statecomm, comm=None)[source]¶
int_general
generates a vector of pseudorandom integers from a discrete distribution with a given PDF (probability density function) or CDF (cumulative distribution function) .For full information please refer to the NAG Library document for g05td
https://support.nag.com/numeric/nl/nagdoc_30.3/flhtml/g05/g05tdf.html
- Parameters
- modeint
A code for selecting the operation to be performed by the function.
Set up reference vector only.
Generate variates using reference vector set up in a prior call to
int_general
.Set up reference vector and generate variates.
Generate variates without using the reference vector.
- nint
, the number of pseudorandom numbers to be generated.
- pfloat, array-like, shape
The PDF or CDF of the distribution.
- ip1int
The value of the variate, a whole number, to which the probability in corresponds.
- itypeint
Indicates the type of information contained in .
contains a probability distribution function (PDF).
contains a cumulative distribution function (CDF).
- statecommdict, RNG communication object, modified in place
RNG communication structure.
This argument must have been initialized by a prior call to
init_repeat()
orinit_nonrepeat()
.- commNone or dict, communication object, optional, modified in place
Communication structure for the reference vector.
If , this argument must have been initialized by a prior call to
int_general
.If , is not referenced and may be None.
- Returns
- xNone or int, ndarray, shape
Contains pseudorandom numbers from the specified discrete distribution.
- Raises
- NagValueError
- (errno )
On entry, .
Constraint: , or .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, at least one element of the vector is less than or greater than .
- (errno )
On entry, and the sum of the elements of do not equal one.
- (errno )
On entry, and the values of are not all in stricly ascending order.
- (errno )
On entry, .
Constraint: if , .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: or .
- (errno )
The value of or is not the same as when [‘r’] was set up in a previous call.
Previous value of and .
Previous value of and .
- (errno )
On entry, some of the elements of the array [‘r’] have been corrupted or have not been initialized.
- (errno )
On entry, [‘state’] vector has been corrupted or not initialized.
- Notes
int_general
generates a sequence of integers , from a discrete distribution defined by information supplied in . 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
int_general
or may be combined in a single call.One of the initialization functions
init_repeat()
(for a repeatable sequence if computed sequentially) orinit_nonrepeat()
(for a non-repeatable sequence) must be called prior to the first call toint_general
.
- References
Kendall, M G and Stuart, A, 1969, The Advanced Theory of Statistics (Volume 1), (3rd Edition), Griffin
Knuth, D E, 1981, The Art of Computer Programming (Volume 2), (2nd Edition), Addison–Wesley