Generates pseudorandom numbers from a logarithmic distribution.
#include <imsls.h>
int *imsls_f_random_logarithmic (int n_random, float a, ..., 0)
The type double function is imsls_d_random_logarithmic.
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.
An integer array of length n_random containing the random logarithmic deviates.
#include <imsls.h>
int
*imsls_f_random_logarithmic (int n_random, float a,
IMSLS_RETURN_USER, int ir[],
0)
IMSLS_RETURN_USER, int ir[]
(Output)
User-supplied integer array of length n_random containing
the random logarithmic deviates.
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.
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>
#include <stdio.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);
}
logarithmic random deviates:
2 1 1 1 2
Visual Numerics, Inc. PHONE: 713.784.3131 FAX:713.781.9260 |