TestResult

data class TestResult(val testName: String, val statistic: Double, val pValue: Double, val degreesOfFreedom: Double = Double.NaN, val alternative: Alternative = Alternative.TWO_SIDED, val confidenceInterval: ConfidenceInterval? = null, val additionalInfo: Map<String, Double> = emptyMap())(source)

The result of a statistical hypothesis test.

Contains the test statistic, p-value, and optional additional information such as degrees of freedom and a confidence interval. Use isSignificant to quickly check whether the result is statistically significant at a given significance level.

Example:

val result = tTest(sample = doubleArrayOf(2.1, 2.5, 2.3, 2.8), mu = 2.0)
result.statistic // t-statistic value
result.pValue // p-value
result.isSignificant() // true/false at alpha = 0.05
result.confidenceInterval // (lower, upper) bounds for the estimated mean

Constructors

Link copied to clipboard
constructor(testName: String, statistic: Double, pValue: Double, degreesOfFreedom: Double = Double.NaN, alternative: Alternative = Alternative.TWO_SIDED, confidenceInterval: ConfidenceInterval? = null, additionalInfo: Map<String, Double> = emptyMap())

Properties

Link copied to clipboard

a map of supplementary statistics (e.g. "mean", "standardError", "oddsRatio") that vary by test type. Defaults to an empty map.

Link copied to clipboard

the direction of the alternative hypothesis that was tested. Defaults to Alternative.TWO_SIDED.

Link copied to clipboard

the confidence interval for the estimated parameter, or null if not computed. Defaults to null.

Link copied to clipboard

the degrees of freedom for the test distribution, or Double.NaN if not applicable. Defaults to Double.NaN.

Link copied to clipboard

the probability of observing a test statistic at least as extreme as the computed value, assuming the null hypothesis is true. Smaller values indicate stronger evidence against the null hypothesis.

Link copied to clipboard

the computed test statistic (e.g. t-value, chi-squared value, U statistic).

Link copied to clipboard

the name of the test that was performed (e.g. "One-Sample t-Test").

Functions

Link copied to clipboard
fun isSignificant(alpha: Double = 0.05): Boolean

Returns true if the test result is statistically significant at the given significance level.