IMSL C Stat Library
random_logarithmic
Generates pseudorandom numbers from a logarithmic distribution.
Synopsis
#include <imsls.h>
int *imsls_f_random_logarithmic(int n_random, float a, 0)
The type double function is imsls_d_random_logarithmic.
Required Arguments
int n_random (Input)
Number of random numbers to generate.
float a (Input)
Parameter of the logarithmic distribution. Parameter a must be positive and less than 1.0.
Return Value
An integer array of length n_random containing the random logarithmic deviates.
Synopsis with Optional Arguments
#include <imsls.h>
int *imsls_f_random_logarithmic (int n_random, float a,
IMSLS_RETURN_USER, int ir[],
0)
Optional Arguments
IMSLS_RETURN_USER, int ir[] (Output)
User-supplied integer array of length n_random containing the random logarithmic deviates.
Description
Function imsls_f_random_logarithmic generates pseudorandom numbers from a logarithmic distribution with parameter a. The probability function is
for x = 1, 2, 3, ..., and 0 < a < 1
The methods used are described by Kemp (1981) and depend on the value of a. If a is less than 0.95, Kemp’s algorithm LS, which is a “chop-down” variant of an inverse CDF technique, is used. Otherwise, Kemp’s algorithm LK, which gives special treatment to the highly probable values of 1 and 2 is used.
Example
In this example, imsls_f_random_logarithmic generates five pseudorandom logarithmic deviates from a logarithmic distribution with parameter a equal to 0.3.
 
#include <imsls.h>
 
int main()
{
int n_random = 5;
float a = 0.3;
int *ir;
 
imsls_random_seed_set(123457);
 
ir = imsls_f_random_logarithmic(n_random, a,
0);
 
imsls_i_write_matrix("logarithmic random deviates:", 1, n_random, ir,
IMSLS_NO_COL_LABELS,
0);
}
Output
 
logarithmic random deviates:
2 1 1 1 2