naginterfaces.library.rand.dist_​triangular

naginterfaces.library.rand.dist_triangular(n, xmin, xmed, xmax, statecomm)[source]

dist_triangular generates a vector of pseudorandom numbers from a triangular distribution with parameters , and .

For full information please refer to the NAG Library document for g05sp

https://support.nag.com/numeric/nl/nagdoc_30.3/flhtml/g05/g05spf.html

Parameters
nint

, the number of pseudorandom numbers to be generated.

xminfloat

The end point of the triangular distribution.

xmedfloat

The median of the distribution (also the location of the vertex of the triangular distribution at which the PDF reaches a maximum).

xmaxfloat

The end point of the triangular distribution.

statecommdict, RNG communication object, modified in place

RNG communication structure.

This argument must have been initialized by a prior call to init_repeat() or init_nonrepeat().

Returns
xfloat, ndarray, shape

The pseudorandom numbers from the specified triangular distribution.

Raises
NagValueError
(errno )

On entry, .

Constraint: .

(errno )

On entry, and .

Constraint: .

(errno )

On entry, and .

Constraint: .

(errno )

On entry, [‘state’] vector has been corrupted or not initialized.

Notes

The triangular distribution has a PDF (probability density function) that is triangular in profile. The base of the triangle ranges from to and the PDF has a maximum value of at . If then with probability 1; otherwise the triangular distribution has PDF:

One of the initialization functions init_repeat() (for a repeatable sequence if computed sequentially) or init_nonrepeat() (for a non-repeatable sequence) must be called prior to the first call to dist_triangular.

References

Knuth, D E, 1981, The Art of Computer Programming (Volume 2), (2nd Edition), Addison–Wesley