random_stable
Generates pseudorandom numbers from a stable distribution.
Synopsis
#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.
Required Arguments
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.
Return Value
An integer array of length n_random containing the random deviates. To release this space, use imsls_free.
Synopsis with Optional Arguments
#include <imsls.h>
float *imsls_f_random_stable (int n_random, float alpha, float bprime,
IMSLS_RETURN_USER, float r[],
0)
Optional Arguments
IMSLS_RETURN_USER, float r[] (Output)
User-supplied array of length n_random containing the random deviates.
Description
Function imsls_f_random_stable generates pseudorandom numbers from a stable distribution with parameters alpha and bprime. alpha is the usual characteristic exponent parameter α and bprime is related to the usual skewness parameter β of the stable distribution. With the restrictions 0 < α 2 and  1 β 1, the characteristic function of the distribution is
φ(t) = exp[-| t |α exp(πiβ(1 - |1 - α|)sign(t)/2)]     for α 1
and
φ(t) = exp[-| t |(1 + 2iβ ln| t |)sign(t)/π)]     for α = 1
When β = 0, the distribution is symmetric. In this case, if α = 2, the distribution is normal with mean 0 and variance 2; and if α = 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 = β’ and the standard β is
β’ = -tan(π(1 - α)/2) tan(-πβ(1 - |1 - α|)/2)     for α 1
and
β’ = β     for α = 1
The algorithm involves formation of the ratio of a uniform and an exponential random variate.
Example
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 <imsls.h>
 
int 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);
}
Output
 
Stable random deviates
4.409
1.056
2.546
5.672
2.166