studentTTestOneSample
Introduced in: v25.10.0
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
CREATE TABLE t (value Float64) ENGINE = Memory;
INSERT INTO t VALUES (20.3), (21.1), (21.9), (21.7), (19.9), (21.8);
SELECT studentTTestOneSample()(value, 20.0) FROM t;┌─studentTTestOneSample(value, 20.)─────────┐
│ (3.2378108288009266,0.023005151817711324) │
└───────────────────────────────────────────┘With confidence interval (95%)
SELECT studentTTestOneSample(0.95)(value, 20.0) FROM t;┌─studentTTestOneSample(0.95)(value, 20.)────────────────────────────────────────┐
│ (3.2378108288009266,0.023005151817711324,20.230116092352564,22.00321724098077) │
└────────────────────────────────────────────────────────────────────────────────┘See Also