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 class
BetaDistribution.Par
Parameterization class-
Nested classes/interfaces inherited from interface elki.math.statistics.distribution.Distribution
Distribution.Parameterizer
-
-
Field Summary
Fields Modifier and Type Field Description private double
alpha
Shape parameter of beta distributionprivate double
beta
Shape parameter of beta distribution(package private) static double[]
GAUSSLEGENDRE_W
Weights for Gauss-Legendre quadrature(package private) static double[]
GAUSSLEGENDRE_Y
Abscissas for Gauss-Legendre quadratureprivate double
logbab
Log beta(a, b) cache(package private) static double
NUM_PRECISION
Numerical precision to use(package private) static double
SWITCH
Limit 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 double
cdf(double x)
Return the cumulative density function at the given value.static double
cdf(double val, double alpha, double beta)
Static version of the CDF of the beta distributionstatic double
logBeta(double alpha, double beta)
Compute log beta(a,b)double
logpdf(double val)
Return the log density of an existing valuestatic double
logpdf(double val, double alpha, double beta)
Static version of the PDF of the beta distributiondouble
nextRandom(java.util.Random random)
Generate a new random valuedouble
pdf(double val)
Return the density of an existing valuestatic double
pdf(double val, double alpha, double beta)
Static version of the PDF of the beta distributiondouble
quantile(double x)
Quantile aka probit (for normal) aka inverse CDF (invcdf, cdf^-1) function.static double
quantile(double p, double alpha, double beta)
Compute quantile (inverse cdf) for Beta distributions.protected static double
rawQuantile(double p, double alpha, double beta, double logbeta)
Raw quantile functionstatic 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.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.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".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".java.lang.String
toString()
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:Distribution
Return the density of an existing value- Specified by:
pdf
in interfaceDistribution
- Parameters:
val
- existing value- Returns:
- distribution density
-
logpdf
public double logpdf(double val)
Description copied from interface:Distribution
Return the log density of an existing value- Specified by:
logpdf
in interfaceDistribution
- Parameters:
val
- existing value- Returns:
- log distribution density
-
cdf
public double cdf(double x)
Description copied from interface:Distribution
Return the cumulative density function at the given value.- Specified by:
cdf
in interfaceDistribution
- Parameters:
x
- existing value- Returns:
- cumulative density
-
quantile
public double quantile(double x)
Description copied from interface:Distribution
Quantile aka probit (for normal) aka inverse CDF (invcdf, cdf^-1) function.- Specified by:
quantile
in interfaceDistribution
- Parameters:
x
- Quantile to find- Returns:
- Quantile position
-
nextRandom
public double nextRandom(java.util.Random random)
Description copied from interface:Distribution
Generate a new random value- Specified by:
nextRandom
in interfaceDistribution
- Parameters:
random
- Random number generator- Returns:
- new random value
-
toString
public java.lang.String toString()
Description copied from interface:Distribution
Describe the distribution- Specified by:
toString
in interfaceDistribution
- Overrides:
toString
in 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
-
-