Chapter 12: Random Number Generation

random_order_uniform

Generates pseudorandom order statistics from a uniform (0, 1) distribution.

Synopsis

#include <imsls.h>

float *imsls_f_random_order_uniform (int ifirst, int ilast,
int n,..., 0)

The type double function is imsls_d_random_order_uniform.

Required Arguments

int ifirst (Input)
First order statistic to generate.

int ilast   (Input)
Last order statistic to generate. 
ilast must be greater than or equal to ifirst. The full set of order statistics from ifirst to ilast is generated. If only one order statistic is desired, set ilast = ifirst.

int n (Input)
Size of the sample from which the order statistics arise.

Return Value

An array of length ilast + 1 - ifirst containing the random order statistics in ascending order. 
The first element is the
ifirst order statistic in a random sample of size n from the uniform (0, 1) distribution. To release this space, use free.

Synopsis with Optional Arguments

#include <imsls.h>

float *imsls_f_random_order_uniform (int ifirst, int ilast, int n,
IMSLS_RETURN_USER, float r[],
 0)

Optional Arguments

IMSLS_RETURN_USER, float r[]  (Output)
User-supplied array of length ilast + 1 - ifirst containing the random order statistics in ascending order.

Description

Routine imsls_f_random_order_uniform generates the ifirst through the ilast order statistics from a pseudorandom sample of size n from a uniform
(0, 1) distribution. Depending on the values of
ifirst and ilast, different methods of generation are used to achieve greater efficiency. If ifirst = 1 and ilast = n, that is, if the full set of order statistics are desired, the spacings between successive order statistics are generated as ratios of exponential variates. If the full set is not desired, a beta variate is generated for one of the order statistics, and the others are generated as extreme order statistics from conditional uniform distributions. Extreme order statistics from a uniform distribution can be obtained by raising a uniform deviate to an appropriate power.

Each call to imsls_f_random_order_uniform yields an independent event. This means, for example, that if on one call the fourth order statistic is requested and on a second call the third order statistic is requested, the “fourth” may be smaller than the “third”. If both the third and fourth order statistics from a given sample are desired, they should be obtained from a single call to imsls_f_random_order_uniform (by specifying ifirst less than or equal to 3 and ilast greater than or equal to 4).

Example

In this example, imsls_f_random_order_uniform is used to generate the fifteenth through the nineteenth order statistics from a sample of size twenty.

 

#include <stdio.h>

#include <imsls.h>

 

int main()

{

  float *r = NULL;

 

  imsls_random_seed_set(123457);

 

  r = imsls_f_random_order_uniform(15, 19, 20, 0);

 

  printf("The 15th through the 19th order statistics from a \n");

  printf("random sample of size 20 from a uniform distribution\n");

  imsls_f_write_matrix("", 5, 1, r, 0);

}

 

Output

The 15th through the 19th order statistics from a

random sample of size 20 from a uniform distribution

 

1      0.6575

2      0.6802

3      0.6807

4      0.8177

5      0.8254


Visual Numerics, Inc.
Visual Numerics - Developers of IMSL and PV-WAVE
http://www.vni.com/
PHONE: 713.784.3131
FAX:713.781.9260