IMSL_RAND_FROM_DATA

Syntax | Return Value | Arguments | Keywords | Discussion | Example | Version History

The IMSL_RAND_FROM_DATA function generates pseudorandom numbers from a multivariate distribution determined from a given sample.

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

Syntax

Result = IMSL_RAND_FROM_DATA(n_random, x, nn [, /DOUBLE])

Return Value

n x ndim matrix containing the random multivariate vectors in its rows.

Arguments

n_random

Number of random multivariate vectors to generate.

nn

Number of nearest neighbors of the randomly selected point in x that are used to form the output point in the result.

x

Two dimensional array of size nsamp by ndim containing the given sample.

Keywords

DOUBLE

If present and nonzero, double precision is used.

Discussion

Given a sample of size nsamp of observations of a k-variate random variable, IMSL_RAND_FROM_DATA generates a pseudorandom sample with approximately the same moments as the given sample. The sample obtained is the same as if sampling from a Gaussian kernel estimate of the sample density. (See Thompson 1989.) Routine IMSL_RAND_FROM_DATA uses methods described by Taylor and Thompson (1986).

Assume that the (vector-valued) observations xi are in the rows of x. An observation, xj, is chosen randomly; its nearest m (= nn) neighbors:

IMSL_RAND_FROM_DATA-29.jpg

are determined; and the mean:

IMSL_RAND_FROM_DATA-30.jpg

of those nearest neighbors is calculated. Next, a random sample u1, u2, ..., um is generated from a uniform distribution with lower bound:

IMSL_RAND_FROM_DATA-31.jpg

and upper bound:

IMSL_RAND_FROM_DATA-32.jpg

The random variate delivered is:

IMSL_RAND_FROM_DATA-33.jpg

The process is then repeated until n such simulated variates are generated and stored in the rows of the result.

Example

In this example, IMSL_RAND_FROM_DATA is used to generate 5 pseudorandom vectors of length 4 using the initial and final systolic pressure and the initial and final diastolic pressure from Data Set A in Afifi and Azen (1979) as the fixed sample from the population to be modeled. (Values of these four variables are in the seventh, tenth, twenty-first, and twenty-fourth columns of data set number nine in routine IMSL_STATDATA, see Math and Statistics Utilities of this manual).

IMSL_RANDOMOPT, Set = 123457 
r = IMSL_STATDATA(9) 
x = FLTARR(113, 4) 
x(*, 0) = r(*,6) 
x(*, 1) = r(*,9) 
x(*, 2) = r(*,20) 
x(*, 3) = r(*,23)  
r  =  IMSL_RAND_FROM_DATA(5, x, 5) 
PM, r 
 
   162.767      90.5057      153.717      104.877 
   153.353      78.3180      176.664      85.2155 
   93.6958      48.1675      153.549      71.3688 
   101.751      54.1855      113.121      56.2916 
   91.7403      58.7684      48.4368      28.0994 

Version History

6.4

Introduced