Class BetaDistribution.ChengBetaSampler

java.lang.Object
org.apache.commons.math3.distribution.BetaDistribution.ChengBetaSampler
Enclosing class:
BetaDistribution

private static final class BetaDistribution.ChengBetaSampler extends Object
Utility class implementing Cheng's algorithms for beta distribution sampling.

R. C. H. Cheng, "Generating beta variates with nonintegral shape parameters.". Communications of the ACM, 21, 317–322, 1978.

Since:
3.6
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private static double
    algorithmBB(RandomGenerator random, double a0, double a, double b)
    Returns one sample using Cheng's BB algorithm, when both α and β are greater than 1.
    private static double
    algorithmBC(RandomGenerator random, double a0, double a, double b)
    Returns one sample using Cheng's BC algorithm, when at least one of α and β is smaller than 1.
    (package private) static double
    sample(RandomGenerator random, double alpha, double beta)
    Returns one sample using Cheng's sampling algorithm.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ChengBetaSampler

      private ChengBetaSampler()
  • Method Details

    • sample

      static double sample(RandomGenerator random, double alpha, double beta)
      Returns one sample using Cheng's sampling algorithm.
      Parameters:
      random - random generator to use
      alpha - distribution first shape parameter
      beta - distribution second shape parameter
      Returns:
      sampled value
    • algorithmBB

      private static double algorithmBB(RandomGenerator random, double a0, double a, double b)
      Returns one sample using Cheng's BB algorithm, when both α and β are greater than 1.
      Parameters:
      random - random generator to use
      a0 - distribution first shape parameter (α)
      a - min(α, β) where α, β are the two distribution shape parameters
      b - max(α, β) where α, β are the two distribution shape parameters
      Returns:
      sampled value
    • algorithmBC

      private static double algorithmBC(RandomGenerator random, double a0, double a, double b)
      Returns one sample using Cheng's BC algorithm, when at least one of α and β is smaller than 1.
      Parameters:
      random - random generator to use
      a0 - distribution first shape parameter (α)
      a - max(α, β) where α, β are the two distribution shape parameters
      b - min(α, β) where α, β are the two distribution shape parameters
      Returns:
      sampled value