Class StableSampler.BaseStableSampler
java.lang.Object
org.apache.commons.rng.sampling.distribution.StableSampler
org.apache.commons.rng.sampling.distribution.StableSampler.BaseStableSampler
- All Implemented Interfaces:
ContinuousSampler, SharedStateContinuousSampler, SharedStateSampler<SharedStateContinuousSampler>
- Direct Known Subclasses:
StableSampler.Alpha1CMSStableSampler, StableSampler.Beta0WeronStableSampler, StableSampler.CauchyStableSampler, StableSampler.WeronStableSampler
- Enclosing class:
StableSampler
Base class for implementations of a stable distribution that requires an exponential
random deviate.
- 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 final ContinuousSamplerThe exponential sampler.private static final double-pi / 2.private static final double-pi / 4.private static final doublepi/2 scaled by 2^-53.private static final doublepi/4 scaled by 2^-53. -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class StableSampler
nextLong, of, of, sample, toString, withUniformRandomProviderMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ContinuousSampler
samples, samples
-
Field Details
-
PI_2_SCALED
private static final double PI_2_SCALEDpi/2 scaled by 2^-53.- See Also:
-
PI_4_SCALED
private static final double PI_4_SCALEDpi/4 scaled by 2^-53.- See Also:
-
NEG_PI_2
private static final double NEG_PI_2-pi / 2.- See Also:
-
NEG_PI_4
private static final double NEG_PI_4-pi / 4.- See Also:
-
expSampler
The exponential sampler.
-
-
Constructor Details
-
BaseStableSampler
BaseStableSampler(UniformRandomProvider rng) - Parameters:
rng- Underlying source of randomness
-
-
Method Details
-
getOmega
double getOmega()Gets a random value for the omega parameter (w). This is an exponential random variable with mean 1.Warning: For simplicity this does not check the variate is not 0. The calling CMS algorithm should detect and handle incorrect samples as a result of this unlikely edge case.
- Returns:
- omega
-
getPhi
double getPhi()Gets a random value for the phi parameter. This is a uniform random variable in(-pi/2, pi/2).- Returns:
- phi
-
getPhiBy2
double getPhiBy2()Gets a random value for the phi parameter divided by 2. This is a uniform random variable in(-pi/4, pi/4).Note: Ideally this should not have a value of -pi/4 or pi/4 as the CMS algorithm can generate infinite values when the phi/2 uniform deviate is +/-pi/4. This can result in NaN output. Under certain parameterizations phi/2 close to the limits also create NaN output. Thus output should be checked regardless. Avoiding the extreme values simplifies the number of checks that are required.
- Returns:
- phi / 2
-