Generates pseudorandom numbers from a stable distribution.
#include <imsls.h>
float
*imsls_f_random_stable (int
n_random,
float
alpha,
float
bprime,
..., 0)
The type double function is imsls_d_random_stable.
int n_random
(Input)
Number of random numbers to generate.
float alpha
(Input)
Characteristic exponent of the stable
distribution. This parameter must be positive and less than or equal to
2.
float bprime
(Input)
Skewness parameter of the stable
distribution. When bprime = 0, the distribution is symmetric. Unless alpha = 1, bprime is not the usual skewness parameter of the stable
distribution. bprime must be greater than or equal to - 1
and less than or equal to 1.
An integer array of length n_random containing the random deviates. To release this space, use free.
#include <imsls.h>
float
*imsls_f_random_binomial (int
n_random,
float
alpha,
float
bprime,
IMSLS_RETURN_USER, float
r[],
0)
IMSLS_RETURN_USER, float r[]
(Output)
User-supplied array of length n_random containing
the random deviates.
Function imsls_f_random_stable generates pseudorandom numbers from a stable distribution with parameters alpha and bprime. alpha is the usual characteristic exponent parameter a and bprime is related to the usual skewness parameter b of the stable distribution. With the restrictions 0 < a £ 2 and - 1 £ b £ 1, the characteristic function of the distribution is
j(t) = exp[-| t |α exp(-pib(1 - |1 - a|)sign(t)/2)] for a ¹ 1
and
j(t) = exp[-| t |(1 + 2ib ln| t |)sign(t)/p)] for a = 1
When b = 0, the distribution is symmetric. In this case, if a = 2, the distribution is normal with mean 0 and variance 2; and if a = 1, the distribution is Cauchy.
The parameterization using bprime and the algorithm used here are due to Chambers, Mallows, and Stuck (1976). The relationship between bprime = b¢ and the standard b is
b¢ = -tan(p(1 - a)/2) tan(-pb(1 - |1 - a|)/2) for a ¹ 1
and
b¢ = b for a = 1
The algorithm involves formation of the ratio of a uniform and an exponential random variate.
In this example, imsls_f_random_stable is used to generate five pseudorandom symmetric stable variates with characteristic exponent 1.5. The tails of this distribution are heavier than those of a normal distribution, but not so heavy as those of a Cauchy distribution. The variance of this distribution does not exist, however. (This is the case for any stable distribution with characteristic exponent less than 2.)
#include <stdio.h>
#include <imsls.h>
void main()
{
int nr = 5;
float alpha = 1.5, bprime = 0.0, *r;
imsls_random_seed_set(123457);
r = imsls_f_random_stable(nr, alpha, bprime, 0);
imsls_f_write_matrix("Stable random deviates", 5, 1, r,
IMSLS_NO_ROW_LABELS, 0);
}
Stable random deviates
4.409
1.056
2.546
5.672
2.166
Visual Numerics, Inc. PHONE: 713.784.3131 FAX:713.781.9260 |