statalign.utils
Class BetaDistribution

java.lang.Object
  extended by org.apache.commons.math3.distribution.AbstractRealDistribution
      extended by statalign.utils.BetaDistribution
All Implemented Interfaces:
java.io.Serializable, org.apache.commons.math3.distribution.RealDistribution

public class BetaDistribution
extends org.apache.commons.math3.distribution.AbstractRealDistribution

Implements the Beta distribution. Adapted from Apache Commons Math v3.0, but modified to use Utils.generator as the random number source.

Since:
2.0 (changed to concrete class in 3.0)
Version:
$Id: BetaDistribution.java 1369202 2012-08-03 20:50:33Z erans $
See Also:
Beta distribution, Serialized Form

Field Summary
static double DEFAULT_INVERSE_ABSOLUTE_ACCURACY
          Default inverse cumulative probability accuracy.
 
Fields inherited from class org.apache.commons.math3.distribution.AbstractRealDistribution
SOLVER_DEFAULT_ABSOLUTE_ACCURACY
 
Constructor Summary
BetaDistribution(double alpha, double beta)
          Build a new instance.
BetaDistribution(double alpha, double beta, double inverseCumAccuracy)
          Build a new instance.
BetaDistribution(org.apache.commons.math3.random.RandomGenerator rng, double alpha, double beta, double inverseCumAccuracy)
          Creates a β distribution.
 
Method Summary
 double cumulativeProbability(double x)
          
 double density(double x)
          
 double getAlpha()
          Access the first shape parameter, alpha.
 double getBeta()
          Access the second shape parameter, beta.
 double getNumericalMean()
           For first shape parameter alpha and second shape parameter beta, the mean is alpha / (alpha + beta).
 double getNumericalVariance()
           For first shape parameter alpha and second shape parameter beta, the variance is (alpha * beta) / [(alpha + beta)^2 * (alpha + beta + 1)].
 double getSupportLowerBound()
           The lower bound of the support is always 0 no matter the parameters.
 double getSupportUpperBound()
           The upper bound of the support is always 1 no matter the parameters.
 boolean isSupportConnected()
           The support of this distribution is connected.
 boolean isSupportLowerBoundInclusive()
          
 boolean isSupportUpperBoundInclusive()
          
 
Methods inherited from class org.apache.commons.math3.distribution.AbstractRealDistribution
cumulativeProbability, inverseCumulativeProbability, probability, probability, reseedRandomGenerator, sample, sample
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_INVERSE_ABSOLUTE_ACCURACY

public static final double DEFAULT_INVERSE_ABSOLUTE_ACCURACY
Default inverse cumulative probability accuracy.

Since:
2.1
See Also:
Constant Field Values
Constructor Detail

BetaDistribution

public BetaDistribution(double alpha,
                        double beta)
Build a new instance.

Parameters:
alpha - First shape parameter (must be positive).
beta - Second shape parameter (must be positive).

BetaDistribution

public BetaDistribution(double alpha,
                        double beta,
                        double inverseCumAccuracy)
Build a new instance.

Parameters:
alpha - First shape parameter (must be positive).
beta - Second shape parameter (must be positive).
inverseCumAccuracy - Maximum absolute error in inverse cumulative probability estimates (defaults to DEFAULT_INVERSE_ABSOLUTE_ACCURACY).
Since:
2.1

BetaDistribution

public BetaDistribution(org.apache.commons.math3.random.RandomGenerator rng,
                        double alpha,
                        double beta,
                        double inverseCumAccuracy)
Creates a β distribution.

Parameters:
rng - Random number generator.
alpha - First shape parameter (must be positive).
beta - Second shape parameter (must be positive).
inverseCumAccuracy - Maximum absolute error in inverse cumulative probability estimates (defaults to DEFAULT_INVERSE_ABSOLUTE_ACCURACY).
Since:
3.1
Method Detail

getAlpha

public double getAlpha()
Access the first shape parameter, alpha.

Returns:
the first shape parameter.

getBeta

public double getBeta()
Access the second shape parameter, beta.

Returns:
the second shape parameter.

density

public double density(double x)


cumulativeProbability

public double cumulativeProbability(double x)


getNumericalMean

public double getNumericalMean()
For first shape parameter alpha and second shape parameter beta, the mean is alpha / (alpha + beta).


getNumericalVariance

public double getNumericalVariance()
For first shape parameter alpha and second shape parameter beta, the variance is (alpha * beta) / [(alpha + beta)^2 * (alpha + beta + 1)].


getSupportLowerBound

public double getSupportLowerBound()
The lower bound of the support is always 0 no matter the parameters.

Returns:
lower bound of the support (always 0)

getSupportUpperBound

public double getSupportUpperBound()
The upper bound of the support is always 1 no matter the parameters.

Returns:
upper bound of the support (always 1)

isSupportLowerBoundInclusive

public boolean isSupportLowerBoundInclusive()


isSupportUpperBoundInclusive

public boolean isSupportUpperBoundInclusive()


isSupportConnected

public boolean isSupportConnected()
The support of this distribution is connected.

Returns:
true