RANDFUN (N, "Distribution" <, param1> <, param2> <, param3>);
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 N 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]N[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:
the Bernoulli distribution with probability
the uniform distribution on the interval
the normal distribution with mean 5 and standard deviation 2
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 25.302: Random Samples from Three Distributions