studentTTestOneSample
Applies the one-sample Student's t-test to determine whether the mean of a sample differs from a known population mean.
This page describes the RawTree engine binary used to generate this reference. It does not define Query API support. Descriptions retain upstream ClickHouse terminology. See SQL interface scope.
Applies the one-sample Student's t-test to determine whether the mean of a sample differs from a known population mean.
Normality is assumed. The null hypothesis is that the sample mean equals the population mean.
The optional confidence_level enables confidence interval calculation.
Notes:
- At least 2 observations are required; otherwise the result is
(nan, nan)(and intervals if requested arenan). - Constant or near-constant input will also return
nandue to zero (or effectively zero) standard error.
See Also
Syntax
studentTTestOneSample([confidence_level])(sample_data, population_mean)Parameters
confidence_level— Optional. Confidence level for confidence intervals. Float in (0, 1).Float*
Arguments
sample_data— Sample data.IntegerorFloatorDecimalpopulation_mean— Known population mean to test against (usually a constant).(U)Int*orFloat*orDecimal
Returned value
Returns a tuple with two or four elements (if confidence_level is specified): calculated t-statistic, calculated p-value (two-tailed), [calculated confidence-interval-low], [calculated confidence-interval-high]. Confidence intervals are for the sample mean at the given confidence level. Tuple(Float64, Float64) or Tuple(Float64, Float64, Float64, Float64)
Examples
Without confidence interval
SELECT studentTTestOneSample()(value, 20.0) FROM t;With confidence interval (95%)
SELECT studentTTestOneSample(0.95)(value, 20.0) FROM t;Introduced in version 25.10.0.