FDistribution

class FDistribution(val dfNumerator: Double, val dfDenominator: Double) : ContinuousDistribution(source)

Represents the F-distribution (also known as the Fisher-Snedecor distribution).

The F-distribution arises as the ratio of two independent chi-squared random variables, each divided by its degrees of freedom. It is the workhorse distribution behind F-tests, which appear in analysis of variance (ANOVA), regression significance testing, and comparing the variances of two populations.

The distribution is right-skewed and supported on the interval from zero to positive infinity. As both degrees-of-freedom parameters grow, it converges toward a normal distribution. The mean exists only when the denominator degrees of freedom exceeds 2, and the variance exists only when it exceeds 4.

Internally, the CDF and survival function use the regularized incomplete beta function, and the quantile function uses Newton's method. Random sampling generates two independent chi-squared variates and computes their ratio.

Example:

val f = FDistribution(dfNumerator = 5.0, dfDenominator = 10.0)
f.pdf(1.0) // 0.6092... (density at x = 1)
f.cdf(3.33) // ~0.95 (probability that F <= 3.33)
f.quantile(0.95) // ~3.33 (critical value for a 5% upper-tail test)
f.mean // 1.25 (10 / (10 - 2))
f.sample(Random(42)) // a single random draw from the distribution

Constructors

Link copied to clipboard
constructor(dfNumerator: Double, dfDenominator: Double)

Properties

Link copied to clipboard

the degrees of freedom for the denominator (second) chi-squared variable. Must be positive.

Link copied to clipboard

the degrees of freedom for the numerator (first) chi-squared variable. Must be positive.

Link copied to clipboard
open override val entropy: Double

The differential entropy of this distribution.

Link copied to clipboard
open override val kurtosis: Double

Returns the excess kurtosis, defined only when the denominator degrees of freedom exceeds 8. Returns Double.NaN otherwise.

Link copied to clipboard
open override val mean: Double

Returns the mean, defined only when the denominator degrees of freedom exceeds 2. Returns Double.NaN otherwise.

Link copied to clipboard
open override val skewness: Double

Returns the skewness, defined only when the denominator degrees of freedom exceeds 6. Returns Double.NaN otherwise.

Link copied to clipboard
open override val variance: Double

Returns the variance, defined only when the denominator degrees of freedom exceeds 4. Returns Double.NaN otherwise.

Functions

Link copied to clipboard
open override fun cdf(x: Double): Double

Returns the cumulative distribution function value at x.

Link copied to clipboard
open override fun logPdf(x: Double): Double

Returns the natural logarithm of the probability density at x.

Link copied to clipboard
open override fun pdf(x: Double): Double

Returns the probability density at x.

Link copied to clipboard
open override fun quantile(p: Double): Double

Returns the quantile (inverse CDF) for the given probability p.

Link copied to clipboard
open override fun sample(random: Random): Double

Draws a single random value from this F-distribution.

Link copied to clipboard
open override fun sf(x: Double): Double

Returns the survival function value at x, equal to 1 - cdf(x).