The IMSL_RAND_GEN_CONT function generates pseudorandom numbers from a general continuous distribution.

This routine requires an IDL Advanced Math and Stats license. For more information, contact your sales or technical support representative.

Routine IMSL_RAND_GEN_CONT generates pseudorandom numbers from a continuous distribution using the inverse CDF technique, by interpolation of points of the distribution function given in table, which is set up by IMSL_CONT_TABLE. A strictly monotone increasing distribution function is assumed. The interpolation is by an algorithm attributable to Akima (1970), using piecewise cubics. The use of this technique for generation of random numbers is due to Guerra, Tapia, and Thompson (1976), who give a description of the algorithm and accuracy comparisons between this method and linear interpolation. The relative errors using the Akima interpolation are generally considered very good.

Examples


In this example, IMSL_RAND_GEN_CONT is used to set up a table for generation of beta pseudorandom deviates. The CDF for this distribution is computed by the routine IMSL_BETACDF. The table contains 100 points at which the CDF is evaluated and that are used for interpolation. Notice that two warnings are issued during the computations for this example.

.RUN
FUNCTION cdf, x
return, IMSL_BETACDF(x, 3., 2.)
END
 
iopt = 0
ndata = 100;
table = FLTARR(100, 5)
x = 0.0;
table(*,0) = FINDGEN(100)/100.
IMSL_CONT_TABLE, 'cdf', iopt, ndata, table
IMSL_RANDOMOPT, Set = 123457
r = IMSL_RAND_GEN_CONT(5, table)
PM, r
 
0.92079391
0.46412855
0.76678398
0.65357975
0.81706959

Syntax


Result = IMSL_RAND_GEN_CONT(N, Table [, /DOUBLE])

Return Value


An array of length n containing the random deviates.

Arguments


N

Number of random numbers to generate.

Table

A two-dimensional array setup using IMSL_CONT_TABLE to be used for interpolation of the cumulative distribution function. The first column of table contains abscissas of the cumulative distribution function in ascending order, the second column contains the values of the CDF (which must be strictly increasing beginning with 0.0 and ending at 1.0) and the remaining columns contain values used in interpolation.

Keywords


DOUBLE (optional)

If present and nonzero, double precision is used.

Version History


6.4

Introduced

See Also


IMSL_CONT_TABLE, IMSL_RANDOM, Overview of Random Number Generation