in commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/StableSampler.java [1397:1445]
private static StableSampler create(UniformRandomProvider rng,
double alpha,
double beta) {
// Choose the algorithm.
// The special case samplers have transformation support and use gamma=1.0, delta=0.0.
// As alpha -> 0 the computation increasingly requires correction
// of infinity to the distribution support.
if (alpha == ALPHA_GAUSSIAN) {
// Note: beta has no effect and is ignored.
return new GaussianStableSampler(rng, GAMMA_1, DELTA_0);
}
// Note: As beta -> 0 the result cannot be computed differently to beta = 0.
// This is based on the computation factor tau:
final double tau = CMSStableSampler.getTau(alpha, beta);
if (tau == TAU_ZERO) {
// Symmetric case (beta skew parameter is effectively zero)
if (alpha == ALPHA_CAUCHY) {
return new CauchyStableSampler(rng, GAMMA_1, DELTA_0);
}
if (alpha <= ALPHA_SMALL) {
// alpha -> 0 requires robust error correction
return new Beta0WeronStableSampler(rng, alpha);
}
return new Beta0CMSStableSampler(rng, alpha);
}
// Here beta is significant.
if (alpha == 1) {
return new Alpha1CMSStableSampler(rng, beta);
}
if (alpha == ALPHA_LEVY && Math.abs(beta) == BETA_LEVY) {
// Support mirroring for negative beta by inverting the beta=1 Levy sample
// using a negative gamma. Note: The delta is not mirrored as it is a shift
// applied to the scaled and mirrored distribution.
return new LevyStableSampler(rng, beta, DELTA_0);
}
if (alpha <= ALPHA_SMALL) {
// alpha -> 0 requires robust error correction
return new WeronStableSampler(rng, alpha, beta);
}
return new CMSStableSampler(rng, alpha, beta);
}