Language Reference

RANDFUN Function

RANDFUN (N, "Distribution" <, param1> <, param2> <, param3>) ;

This function is supported by the IML procedure and the iml action.

The RANDFUN function is part of the IMLMLIB library. The RANDFUN function is a convenient interface to the RANDGEN subroutine. If N is a positive integer, the function returns an Ntimes 1 column vector of random numbers that are drawn from the Distribution family with the specified parameters. If N is a vector that contains a pair of integers, the function returns an N[1]timesN[2] matrix of random numbers.

For simulation studies that generate matrices of random numbers within a DO loop, it is more efficient to use the RANDGEN subroutine.

The following example simulates data from three distributions:

call randseed(123);
b = randfun({4 2}, "Bernoulli", 0.5); /* 4 rows, 2 cols */
u = randfun(4, "Uniform");
x = randfun(4, "Normal", 5, 2);
print b u x;

Figure 339: Random Samples from Three Distributions

b ux
010.0567014.956251
110.07983055.8587927
110.92337355.9284455
110.22585096.2806841


Last updated: April 16, 2021