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
private abstract static class StableSampler.BaseStableSampler extends StableSampler
Base class for implementations of a stable distribution that requires an exponential random deviate.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.commons.rng.sampling.distribution.StableSampler
StableSampler.Alpha1CMSStableSampler, StableSampler.Beta0CMSStableSampler, StableSampler.Beta0WeronStableSampler, StableSampler.CMSStableSampler, StableSampler.SpecialMath, StableSampler.WeronStableSampler
-
-
Field Summary
Fields Modifier and Type Field Description private ContinuousSampler
expSampler
The exponential sampler.private static double
NEG_PI_2
-pi / 2.private static double
NEG_PI_4
-pi / 4.private static double
PI_2_SCALED
pi/2 scaled by 2^-53.private static double
PI_4_SCALED
pi/4 scaled by 2^-53.
-
Constructor Summary
Constructors Constructor Description BaseStableSampler(UniformRandomProvider rng)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) double
getOmega()
Gets a random value for the omega parameter (w
).(package private) double
getPhi()
Gets a random value for the phi parameter.(package private) double
getPhiBy2()
Gets a random value for the phi parameter divided by 2.-
Methods inherited from class org.apache.commons.rng.sampling.distribution.StableSampler
nextLong, of, of, sample, toString, withUniformRandomProvider
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.commons.rng.sampling.distribution.ContinuousSampler
samples, samples
-
-
-
-
Field Detail
-
PI_2_SCALED
private static final double PI_2_SCALED
pi/2 scaled by 2^-53.- See Also:
- Constant Field Values
-
PI_4_SCALED
private static final double PI_4_SCALED
pi/4 scaled by 2^-53.- See Also:
- Constant Field Values
-
NEG_PI_2
private static final double NEG_PI_2
-pi / 2.- See Also:
- Constant Field Values
-
NEG_PI_4
private static final double NEG_PI_4
-pi / 4.- See Also:
- Constant Field Values
-
expSampler
private final ContinuousSampler expSampler
The exponential sampler.
-
-
Constructor Detail
-
BaseStableSampler
BaseStableSampler(UniformRandomProvider rng)
- Parameters:
rng
- Underlying source of randomness
-
-
Method Detail
-
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
-
-