Top Description Fields Constructors Methods
org.apache.commons.math3.distribution

public Class FDistribution

extends AbstractRealDistribution
Class Inheritance
Imports
org.apache.commons.math3.exception.NotStrictlyPositiveException, org.apache.commons.math3.exception.util.LocalizedFormats, org.apache.commons.math3.random.RandomGenerator, .Well19937c, org.apache.commons.math3.special.Beta, org.apache.commons.math3.util.FastMath

Implementation of the F-distribution.
See Also
F-distribution (Wikipedia), F-distribution (MathWorld)

Field Summary

Modifier and TypeField and Description
public static final double
DEFAULT_INVERSE_ABSOLUTE_ACCURACY

Default inverse cumulative probability accuracy.

private final double
denominatorDegreesOfFreedom

The numerator degrees of freedom.

private final double
numeratorDegreesOfFreedom

The numerator degrees of freedom.

private double
numericalVariance

Cached numerical variance

private boolean
numericalVarianceIsCalculated

Whether or not the numerical variance has been calculated

private static final long
private final double
Inherited from org.apache.commons.math3.distribution.AbstractRealDistribution:
randomrandomDataSOLVER_DEFAULT_ABSOLUTE_ACCURACY

Constructor Summary

AccessConstructor and Description
public
FDistribution(double
Numerator degrees of freedom.
numeratorDegreesOfFreedom
,
double
Denominator degrees of freedom.
denominatorDegreesOfFreedom
)

Creates an F distribution using the given degrees of freedom.

public
FDistribution(double
Numerator degrees of freedom.
numeratorDegreesOfFreedom
,
double
Denominator degrees of freedom.
denominatorDegreesOfFreedom
,
double
the maximum absolute error in inverse cumulative probability estimates.
inverseCumAccuracy
)

Creates an F distribution using the given degrees of freedom and inverse cumulative probability accuracy.

public
FDistribution(RandomGenerator
Random number generator.
rng
,
double
Numerator degrees of freedom.
numeratorDegreesOfFreedom
,
double
Denominator degrees of freedom.
denominatorDegreesOfFreedom
)

Creates an F distribution.

public
FDistribution(RandomGenerator
Random number generator.
rng
,
double
Numerator degrees of freedom.
numeratorDegreesOfFreedom
,
double
Denominator degrees of freedom.
denominatorDegreesOfFreedom
,
double
the maximum absolute error in inverse cumulative probability estimates.
inverseCumAccuracy
)

Creates an F distribution.

Method Summary

Modifier and TypeMethod and Description
protected double

Returns:

the variance of this distribution
calculateNumericalVariance
()

used by getNumericalVariance()

public double
cumulativeProbability(double
the point at which the CDF is evaluated
x
)

Implements org.apache.commons.math3.distribution.RealDistribution.cumulativeProbability.

For a random variable X whose values are distributed according to this distribution, this method returns P(X <= x).

public double
density(double
the point at which the PDF is evaluated
x
)

Implements org.apache.commons.math3.distribution.RealDistribution.density.

Returns the probability density function (PDF) of this distribution evaluated at the specified point x.

public double

Returns:

the denominator degrees of freedom.
getDenominatorDegreesOfFreedom
()

Access the denominator degrees of freedom.

public double

Returns:

the numerator degrees of freedom.
getNumeratorDegreesOfFreedom
()

Access the numerator degrees of freedom.

public double
getNumericalMean()

Implements org.apache.commons.math3.distribution.RealDistribution.getNumericalMean.

Use this method to get the numerical value of the mean of this distribution.

public double
getNumericalVariance()

Implements org.apache.commons.math3.distribution.RealDistribution.getNumericalVariance.

Use this method to get the numerical value of the variance of this distribution.

protected double
getSolverAbsoluteAccuracy()

Overrides org.apache.commons.math3.distribution.AbstractRealDistribution.getSolverAbsoluteAccuracy.

Returns the solver absolute accuracy for inverse cumulative computation.

public double

Returns:

lower bound of the support (always 0)
getSupportLowerBound
()

Implements org.apache.commons.math3.distribution.RealDistribution.getSupportLowerBound.

Access the lower bound of the support.

public double

Returns:

upper bound of the support (always Double.POSITIVE_INFINITY)
getSupportUpperBound
()

Implements org.apache.commons.math3.distribution.RealDistribution.getSupportUpperBound.

Access the upper bound of the support.

public boolean

Returns:

true
isSupportConnected
()

Implements org.apache.commons.math3.distribution.RealDistribution.isSupportConnected.

Use this method to get information about whether the support is connected, i.e. whether all values between the lower and upper bound of the support are included in the support.

public boolean
isSupportLowerBoundInclusive()

Implements org.apache.commons.math3.distribution.RealDistribution.isSupportLowerBoundInclusive.

Whether or not the lower bound of support is in the domain of the density function.

public boolean
isSupportUpperBoundInclusive()

Implements org.apache.commons.math3.distribution.RealDistribution.isSupportUpperBoundInclusive.

Whether or not the upper bound of support is in the domain of the density function.

public double
logDensity(double
the point at which the PDF is evaluated
x
)

Overrides org.apache.commons.math3.distribution.AbstractRealDistribution.logDensity.

Returns the natural logarithm of the probability density function (PDF) of this distribution evaluated at the specified point x.

Inherited from org.apache.commons.math3.distribution.AbstractRealDistribution:
cumulativeProbabilityinverseCumulativeProbabilityprobabilityprobabilityreseedRandomGeneratorsamplesample

Field Detail

DEFAULT_INVERSE_ABSOLUTE_ACCURACYback to summary
public static final double DEFAULT_INVERSE_ABSOLUTE_ACCURACY

Default inverse cumulative probability accuracy.

Since
2.1
denominatorDegreesOfFreedomback to summary
private final double denominatorDegreesOfFreedom

The numerator degrees of freedom.

numeratorDegreesOfFreedomback to summary
private final double numeratorDegreesOfFreedom

The numerator degrees of freedom.

numericalVarianceback to summary
private double numericalVariance

Cached numerical variance

numericalVarianceIsCalculatedback to summary
private boolean numericalVarianceIsCalculated

Whether or not the numerical variance has been calculated

serialVersionUIDback to summary
private static final long serialVersionUID

Hides org.apache.commons.math3.distribution.AbstractRealDistribution.serialVersionUID.

Serializable version identifier.

solverAbsoluteAccuracyback to summary
private final double solverAbsoluteAccuracy

Hides org.apache.commons.math3.distribution.AbstractRealDistribution.solverAbsoluteAccuracy.

Inverse cumulative probability accuracy.

Constructor Detail

FDistributionback to summary
public FDistribution(double numeratorDegreesOfFreedom, double denominatorDegreesOfFreedom) throws NotStrictlyPositiveException

Creates an F distribution using the given degrees of freedom.

Note

this constructor will implicitly create an instance of Well19937c as random generator to be used for sampling only (see sample() and sample(int)). In case no sampling is needed for the created distribution, it is advised to pass null as random generator via the appropriate constructors to avoid the additional initialisation overhead.

Parameters
numeratorDegreesOfFreedom:double

Numerator degrees of freedom.

denominatorDegreesOfFreedom:double

Denominator degrees of freedom.

Exceptions
NotStrictlyPositiveException:
if numeratorDegreesOfFreedom <= 0 or denominatorDegreesOfFreedom <= 0.
FDistributionback to summary
public FDistribution(double numeratorDegreesOfFreedom, double denominatorDegreesOfFreedom, double inverseCumAccuracy) throws NotStrictlyPositiveException

Creates an F distribution using the given degrees of freedom and inverse cumulative probability accuracy.

Note

this constructor will implicitly create an instance of Well19937c as random generator to be used for sampling only (see sample() and sample(int)). In case no sampling is needed for the created distribution, it is advised to pass null as random generator via the appropriate constructors to avoid the additional initialisation overhead.

Parameters
numeratorDegreesOfFreedom:double

Numerator degrees of freedom.

denominatorDegreesOfFreedom:double

Denominator degrees of freedom.

inverseCumAccuracy:double

the maximum absolute error in inverse cumulative probability estimates.

Exceptions
NotStrictlyPositiveException:
if numeratorDegreesOfFreedom <= 0 or denominatorDegreesOfFreedom <= 0.
Since
2.1
FDistributionback to summary
public FDistribution(RandomGenerator rng, double numeratorDegreesOfFreedom, double denominatorDegreesOfFreedom) throws NotStrictlyPositiveException

Creates an F distribution.

Parameters
rng:RandomGenerator

Random number generator.

numeratorDegreesOfFreedom:double

Numerator degrees of freedom.

denominatorDegreesOfFreedom:double

Denominator degrees of freedom.

Exceptions
NotStrictlyPositiveException:
if numeratorDegreesOfFreedom <= 0 or denominatorDegreesOfFreedom <= 0.
Since
3.3
FDistributionback to summary
public FDistribution(RandomGenerator rng, double numeratorDegreesOfFreedom, double denominatorDegreesOfFreedom, double inverseCumAccuracy) throws NotStrictlyPositiveException

Creates an F distribution.

Parameters
rng:RandomGenerator

Random number generator.

numeratorDegreesOfFreedom:double

Numerator degrees of freedom.

denominatorDegreesOfFreedom:double

Denominator degrees of freedom.

inverseCumAccuracy:double

the maximum absolute error in inverse cumulative probability estimates.

Exceptions
NotStrictlyPositiveException:
if numeratorDegreesOfFreedom <= 0 or denominatorDegreesOfFreedom <= 0.
Since
3.1

Method Detail

calculateNumericalVarianceback to summary
protected double calculateNumericalVariance()

used by getNumericalVariance()

Returns:double

the variance of this distribution

cumulativeProbabilityback to summary
public double cumulativeProbability(double x)

Implements org.apache.commons.math3.distribution.RealDistribution.cumulativeProbability.

Doc from org.apache.commons.math3.distribution.RealDistribution.cumulativeProbability.

For a random variable X whose values are distributed according to this distribution, this method returns P(X <= x). In other words, this method represents the (cumulative) distribution function (CDF) for this distribution. The implementation of this method is based on

Parameters
x:double

the point at which the CDF is evaluated

Returns:double

the probability that a random variable with this distribution takes a value less than or equal to x

densityback to summary
public double density(double x)

Implements org.apache.commons.math3.distribution.RealDistribution.density.

Doc from org.apache.commons.math3.distribution.RealDistribution.density.

Returns the probability density function (PDF) of this distribution evaluated at the specified point x. In general, the PDF is the derivative of the CDF. If the derivative does not exist at x, then an appropriate replacement should be returned, e.g. Double.POSITIVE_INFINITY, Double.NaN, or the limit inferior or limit superior of the difference quotient.

Parameters
x:double

the point at which the PDF is evaluated

Returns:double

the value of the probability density function at point x

Since
2.1
getDenominatorDegreesOfFreedomback to summary
public double getDenominatorDegreesOfFreedom()

Access the denominator degrees of freedom.

Returns:double

the denominator degrees of freedom.

getNumeratorDegreesOfFreedomback to summary
public double getNumeratorDegreesOfFreedom()

Access the numerator degrees of freedom.

Returns:double

the numerator degrees of freedom.

getNumericalMeanback to summary
public double getNumericalMean()

Implements org.apache.commons.math3.distribution.RealDistribution.getNumericalMean.

Doc from org.apache.commons.math3.distribution.RealDistribution.getNumericalMean.

Use this method to get the numerical value of the mean of this distribution. For denominator degrees of freedom parameter b, the mean is

  • if b > 2 then b / (b - 2),
  • else undefined (Double.NaN).
Returns:double

the mean or Double.NaN if it is not defined

getNumericalVarianceback to summary
public double getNumericalVariance()

Implements org.apache.commons.math3.distribution.RealDistribution.getNumericalVariance.

Doc from org.apache.commons.math3.distribution.RealDistribution.getNumericalVariance.

Use this method to get the numerical value of the variance of this distribution. For numerator degrees of freedom parameter a and denominator degrees of freedom parameter b, the variance is

  • if b > 4 then [2 * b^2 * (a + b - 2)] / [a * (b - 2)^2 * (b - 4)],
  • else undefined (Double.NaN).
Returns:double

the variance (possibly Double.POSITIVE_INFINITY as for certain cases in TDistribution) or Double.NaN if it is not defined

getSolverAbsoluteAccuracyback to summary
protected double getSolverAbsoluteAccuracy()

Overrides org.apache.commons.math3.distribution.AbstractRealDistribution.getSolverAbsoluteAccuracy.

Doc from org.apache.commons.math3.distribution.AbstractRealDistribution.getSolverAbsoluteAccuracy.

Returns the solver absolute accuracy for inverse cumulative computation. You can override this method in order to use a Brent solver with an absolute accuracy different from the default.

Returns:double

the maximum absolute error in inverse cumulative probability estimates

Annotations
@Override
getSupportLowerBoundback to summary
public double getSupportLowerBound()

Implements org.apache.commons.math3.distribution.RealDistribution.getSupportLowerBound.

Doc from org.apache.commons.math3.distribution.RealDistribution.getSupportLowerBound.

Access the lower bound of the support. This method must return the same value as inverseCumulativeProbability(0). In other words, this method must return

inf {x in R | P(X <= x) > 0}.

The lower bound of the support is always 0 no matter the parameters.
Returns:double

lower bound of the support (always 0)

getSupportUpperBoundback to summary
public double getSupportUpperBound()

Implements org.apache.commons.math3.distribution.RealDistribution.getSupportUpperBound.

Doc from org.apache.commons.math3.distribution.RealDistribution.getSupportUpperBound.

Access the upper bound of the support. This method must return the same value as inverseCumulativeProbability(1). In other words, this method must return

inf {x in R | P(X <= x) = 1}.

The upper bound of the support is always positive infinity no matter the parameters.
Returns:double

upper bound of the support (always Double.POSITIVE_INFINITY)

isSupportConnectedback to summary
public boolean isSupportConnected()

Implements org.apache.commons.math3.distribution.RealDistribution.isSupportConnected.

Doc from org.apache.commons.math3.distribution.RealDistribution.isSupportConnected.

Use this method to get information about whether the support is connected, i.e. whether all values between the lower and upper bound of the support are included in the support. The support of this distribution is connected.

Returns:boolean

true

isSupportLowerBoundInclusiveback to summary
public boolean isSupportLowerBoundInclusive()

Implements org.apache.commons.math3.distribution.RealDistribution.isSupportLowerBoundInclusive.

Doc from org.apache.commons.math3.distribution.RealDistribution.isSupportLowerBoundInclusive.

Whether or not the lower bound of support is in the domain of the density function. Returns true iff getSupporLowerBound() is finite and density(getSupportLowerBound()) returns a non-NaN, non-infinite value.

Returns:boolean

true if the lower bound of support is finite and the density function returns a non-NaN, non-infinite value there

isSupportUpperBoundInclusiveback to summary
public boolean isSupportUpperBoundInclusive()

Implements org.apache.commons.math3.distribution.RealDistribution.isSupportUpperBoundInclusive.

Doc from org.apache.commons.math3.distribution.RealDistribution.isSupportUpperBoundInclusive.

Whether or not the upper bound of support is in the domain of the density function. Returns true iff getSupportUpperBound() is finite and density(getSupportUpperBound()) returns a non-NaN, non-infinite value.

Returns:boolean

true if the upper bound of support is finite and the density function returns a non-NaN, non-infinite value there

logDensityback to summary
public double logDensity(double x)

Overrides org.apache.commons.math3.distribution.AbstractRealDistribution.logDensity.

Doc from org.apache.commons.math3.distribution.AbstractRealDistribution.logDensity.

Returns the natural logarithm of the probability density function (PDF) of this distribution evaluated at the specified point x. In general, the PDF is the derivative of the CDF. If the derivative does not exist at x, then an appropriate replacement should be returned, e.g. Double.POSITIVE_INFINITY, Double.NaN, or the limit inferior or limit superior of the difference quotient. Note that due to the floating point precision and under/overflow issues, this method will for some distributions be more precise and faster than computing the logarithm of density(double). The default implementation simply computes the logarithm of density(x).

Parameters
x:double

the point at which the PDF is evaluated

Returns:double

the logarithm of the value of the probability density function at point x

Annotations
@Override