Class StableSampler.CMSStableSampler
- All Implemented Interfaces:
ContinuousSampler, SharedStateContinuousSampler, SharedStateSampler<SharedStateContinuousSampler>
- Enclosing class:
StableSampler
alpha < 2 and
beta != 0. This routine assumes alpha != 1.
Implements the Chambers-Mallows-Stuck (CMS) method from Chambers, et al (1976) A Method for Simulating Stable Random Variables. Journal of the American Statistical Association Vol. 71, No. 354, pp. 340-344.
The formula produces a stable deviate from the 0-parameterization that is
continuous at alpha=1.
This is an implementation of the Fortran routine RSTAB. In the event the
computation fails then an alternative computation is performed using the
formula provided in Weron (1996) "On the Chambers-Mallows-Stuck method for
simulating skewed stable random variables" Statistics & Probability
Letters. 28 (2): 165–171. This method is easier to correct from infinite and
NaN results. The error correction path is extremely unlikely to occur during
use unless alpha -> 0. In general use it requires the random deviates
w or u are extreme. See the unit tests for conditions that create them.
This produces non-NaN output for all parameters alpha, beta, u and w with the correct orientation for extremes of the distribution support. The formulas used are symmetric with regard to beta and u.
- Since:
- 1.4
-
Nested Class Summary
Nested classes/interfaces inherited from class StableSampler
StableSampler.Alpha1CMSStableSampler, StableSampler.Beta0CMSStableSampler, StableSampler.Beta0WeronStableSampler, StableSampler.CMSStableSampler, StableSampler.SpecialMath, StableSampler.WeronStableSampler -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final double1/2.private final doubleCache of expression value used in generation.Fields inherited from class StableSampler.WeronStableSampler
atanZeta, eps, epsDiv1mEps, inv1mEps, lower, meps1, scale, upper, zeta -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static doublegetTau(double alpha, double beta) Gets tau.doublesample()Generate a sample from a stable distribution.Create a new instance of the sampler with the same underlying state using the given uniform random provider as the source of randomness.Methods inherited from class StableSampler.WeronStableSampler
createSampleMethods inherited from class StableSampler.BaseStableSampler
getOmega, getPhi, getPhiBy2Methods inherited from class StableSampler
nextLong, of, of, toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ContinuousSampler
samples, samples
-
Field Details
-
HALF
private static final double HALF1/2.- See Also:
-
tau
private final double tauCache of expression value used in generation.
-
-
Constructor Details
-
CMSStableSampler
CMSStableSampler(UniformRandomProvider rng, double alpha, double beta) - Parameters:
rng- Underlying source of randomnessalpha- Stability parameter. Must be in the interval(0, 2].beta- Skewness parameter. Must be in the interval[-1, 1].
-
CMSStableSampler
CMSStableSampler(UniformRandomProvider rng, StableSampler.CMSStableSampler source) - Parameters:
rng- Underlying source of randomnesssource- Source to copy.
-
-
Method Details
-
getTau
static double getTau(double alpha, double beta) Gets tau. This is a factor used in the CMS algorithm. If this is zero then a special case ofbeta -> 0has occurred.- Parameters:
alpha- Stability parameter. Must be in the interval(0, 2].beta- Skewness parameter. Must be in the interval[-1, 1].- Returns:
- tau
-
sample
public double sample()Description copied from class:StableSamplerGenerate a sample from a stable distribution.The distribution uses the 0-parameterization: S(alpha, beta, gamma, delta; 0).
- Specified by:
samplein interfaceContinuousSampler- Overrides:
samplein classStableSampler.WeronStableSampler- Returns:
- a sample.
-
withUniformRandomProvider
Description copied from class:StableSamplerCreate a new instance of the sampler with the same underlying state using the given uniform random provider as the source of randomness.- Specified by:
withUniformRandomProviderin interfaceSharedStateSampler<SharedStateContinuousSampler>- Overrides:
withUniformRandomProviderin classStableSampler.WeronStableSampler- Parameters:
rng- Generator of uniformly distributed random numbers.- Returns:
- the sampler
-