Class BetaDistribution
- java.lang.Object
-
- elki.math.statistics.distribution.BetaDistribution
-
- All Implemented Interfaces:
Distribution
public class BetaDistribution extends java.lang.Object implements Distribution
Beta Distribution with implementation of the regularized incomplete beta function- Since:
- 0.5.0
- Author:
- Jan Brusis, Erich Schubert
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBetaDistribution.ParParameterization class-
Nested classes/interfaces inherited from interface elki.math.statistics.distribution.Distribution
Distribution.Parameterizer
-
-
Field Summary
Fields Modifier and Type Field Description private doublealphaShape parameter of beta distributionprivate doublebetaShape parameter of beta distribution(package private) static double[]GAUSSLEGENDRE_WWeights for Gauss-Legendre quadrature(package private) static double[]GAUSSLEGENDRE_YAbscissas for Gauss-Legendre quadratureprivate doublelogbabLog beta(a, b) cache(package private) static doubleNUM_PRECISIONNumerical precision to use(package private) static doubleSWITCHLimit of when to switch to quadrature method
-
Constructor Summary
Constructors Constructor Description BetaDistribution(double a, double b)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description doublecdf(double x)Return the cumulative density function at the given value.static doublecdf(double val, double alpha, double beta)Static version of the CDF of the beta distributionstatic doublelogBeta(double alpha, double beta)Compute log beta(a,b)doublelogpdf(double val)Return the log density of an existing valuestatic doublelogpdf(double val, double alpha, double beta)Static version of the PDF of the beta distributiondoublenextRandom(java.util.Random random)Generate a new random valuedoublepdf(double val)Return the density of an existing valuestatic doublepdf(double val, double alpha, double beta)Static version of the PDF of the beta distributiondoublequantile(double x)Quantile aka probit (for normal) aka inverse CDF (invcdf, cdf^-1) function.static doublequantile(double p, double alpha, double beta)Compute quantile (inverse cdf) for Beta distributions.protected static doublerawQuantile(double p, double alpha, double beta, double logbeta)Raw quantile functionstatic doubleregularizedIncBeta(double x, double alpha, double beta)Computes the regularized incomplete beta function I_x(a, b) which is also the CDF of the beta distribution.protected static doubleregularizedIncBeta(double x, double alpha, double beta, double logbab)Computes the regularized incomplete beta function I_x(a, b) which is also the CDF of the beta distribution.protected static doubleregularizedIncBetaCF(double alpha, double beta, double x)Returns the regularized incomplete beta function I_x(a, b) Includes the continued fraction way of computing, based on the book "Numerical Recipes".protected static doubleregularizedIncBetaQuadrature(double alpha, double beta, double x)Returns the regularized incomplete beta function I_x(a, b) by quadrature, based on the book "Numerical Recipes".java.lang.StringtoString()Describe the distribution
-
-
-
Field Detail
-
NUM_PRECISION
static final double NUM_PRECISION
Numerical precision to use- See Also:
- Constant Field Values
-
SWITCH
static final double SWITCH
Limit of when to switch to quadrature method- See Also:
- Constant Field Values
-
GAUSSLEGENDRE_Y
static final double[] GAUSSLEGENDRE_Y
Abscissas for Gauss-Legendre quadrature
-
GAUSSLEGENDRE_W
static final double[] GAUSSLEGENDRE_W
Weights for Gauss-Legendre quadrature
-
alpha
private final double alpha
Shape parameter of beta distribution
-
beta
private final double beta
Shape parameter of beta distribution
-
logbab
private double logbab
Log beta(a, b) cache
-
-
Method Detail
-
pdf
public double pdf(double val)
Description copied from interface:DistributionReturn the density of an existing value- Specified by:
pdfin interfaceDistribution- Parameters:
val- existing value- Returns:
- distribution density
-
logpdf
public double logpdf(double val)
Description copied from interface:DistributionReturn the log density of an existing value- Specified by:
logpdfin interfaceDistribution- Parameters:
val- existing value- Returns:
- log distribution density
-
cdf
public double cdf(double x)
Description copied from interface:DistributionReturn the cumulative density function at the given value.- Specified by:
cdfin interfaceDistribution- Parameters:
x- existing value- Returns:
- cumulative density
-
quantile
public double quantile(double x)
Description copied from interface:DistributionQuantile aka probit (for normal) aka inverse CDF (invcdf, cdf^-1) function.- Specified by:
quantilein interfaceDistribution- Parameters:
x- Quantile to find- Returns:
- Quantile position
-
nextRandom
public double nextRandom(java.util.Random random)
Description copied from interface:DistributionGenerate a new random value- Specified by:
nextRandomin interfaceDistribution- Parameters:
random- Random number generator- Returns:
- new random value
-
toString
public java.lang.String toString()
Description copied from interface:DistributionDescribe the distribution- Specified by:
toStringin interfaceDistribution- Overrides:
toStringin classjava.lang.Object- Returns:
- description
-
cdf
public static double cdf(double val, double alpha, double beta)Static version of the CDF of the beta distribution- Parameters:
val- Valuealpha- Shape parameter abeta- Shape parameter b- Returns:
- cumulative density
-
pdf
public static double pdf(double val, double alpha, double beta)Static version of the PDF of the beta distribution- Parameters:
val- Valuealpha- Shape parameter abeta- Shape parameter b- Returns:
- probability density
-
logpdf
public static double logpdf(double val, double alpha, double beta)Static version of the PDF of the beta distribution- Parameters:
val- Valuealpha- Shape parameter abeta- Shape parameter b- Returns:
- probability density
-
logBeta
public static double logBeta(double alpha, double beta)Compute log beta(a,b)- Parameters:
alpha- Shape parameter abeta- Shape parameter b- Returns:
- Logarithm of result
-
regularizedIncBeta
public static double regularizedIncBeta(double x, double alpha, double beta)Computes the regularized incomplete beta function I_x(a, b) which is also the CDF of the beta distribution. Based on the book "Numerical Recipes"- Parameters:
alpha- Parameter abeta- Parameter bx- Parameter x- Returns:
- Value of the regularized incomplete beta function
-
regularizedIncBeta
protected static double regularizedIncBeta(double x, double alpha, double beta, double logbab)Computes the regularized incomplete beta function I_x(a, b) which is also the CDF of the beta distribution. Based on the book "Numerical Recipes"- Parameters:
x- Parameter xalpha- Parameter abeta- Parameter blogbab- Cached logBeta(alpha, beta)- Returns:
- Value of the regularized incomplete beta function
-
regularizedIncBetaCF
protected static double regularizedIncBetaCF(double alpha, double beta, double x)Returns the regularized incomplete beta function I_x(a, b) Includes the continued fraction way of computing, based on the book "Numerical Recipes".- Parameters:
alpha- Parameter abeta- Parameter bx- Parameter x- Returns:
- result
-
regularizedIncBetaQuadrature
protected static double regularizedIncBetaQuadrature(double alpha, double beta, double x)Returns the regularized incomplete beta function I_x(a, b) by quadrature, based on the book "Numerical Recipes".- Parameters:
alpha- Parameter abeta- Parameter bx- Parameter x- Returns:
- result
-
quantile
public static double quantile(double p, double alpha, double beta)Compute quantile (inverse cdf) for Beta distributions.- Parameters:
p- Probabilityalpha- Shape parameter abeta- Shape parameter b- Returns:
- Probit for Beta distribution
-
rawQuantile
protected static double rawQuantile(double p, double alpha, double beta, double logbeta)Raw quantile function- Parameters:
p- P, must be 0 < p <= .5alpha- Alphabeta- Betalogbeta- log Beta(alpha, beta)- Returns:
- Position
-
-