leveneTest

fun leveneTest(vararg groups: DoubleArray, center: LeveneCenter = LeveneCenter.MEDIAN): TestResult(source)

Performs Levene's test for equality of variances across two or more groups.

The null hypothesis is that all groups have equal variances (homoscedasticity). The test transforms each observation to its absolute deviation from the group center (mean or median), then performs a one-way ANOVA on the transformed values.

When center is LeveneCenter.MEDIAN, this is the Brown-Forsythe variant, which is more robust against non-normal data. When center is LeveneCenter.MEAN, this is the classic Levene's test, which is more powerful under normality.

Example:

val g1 = doubleArrayOf(10.0, 11.0, 12.0, 9.0, 10.0)
val g2 = doubleArrayOf(5.0, 15.0, 10.0, 20.0, 0.0)
val result = leveneTest(g1, g2)
result.statistic // W (F-statistic on transformed data)
result.pValue // p-value from F-distribution
result.additionalInfo["dfBetween"] // between-group degrees of freedom
result.additionalInfo["dfWithin"] // within-group degrees of freedom

Return

a TestResult containing the W statistic, p-value, and additional info with "dfBetween" and "dfWithin".

Parameters

groups

two or more groups of observations, each with at least 2 elements.

center

the group center statistic used for computing deviations. Defaults to LeveneCenter.MEDIAN (Brown-Forsythe variant).