Skip to main content
Skip to main content

studentTTestOneSample

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.

Syntax

studentTTestOneSample([confidence_level])(sample_data, population_mean)

The optional confidence_level enables confidence interval calculation.

Arguments

  • sample_data — Sample data. Integer, Float or Decimal.
  • population_mean — Known population mean to test against. Integer, Float or Decimal (usually a constant).

Parameters

  • confidence_level — Confidence level for confidence intervals. Float in (0, 1).

Notes:

  • At least 2 observations are required; otherwise the result is (nan, nan) (and intervals if requested are nan).
  • Constant or near-constant input will also return nan due to zero (or effectively zero) standard error.

Returned values

Tuple with two or four elements (if confidence_level is specified):

  • calculated t-statistic. Float64.
  • calculated p-value (two-tailed). Float64.
  • calculated confidence-interval-low. Float64. (optional)
  • calculated confidence-interval-high. Float64. (optional)

Confidence intervals are for the sample mean at the given confidence level.

Examples

Input table:

┌─value─┐
│  20.3 │
│  21.1 │
│  21.7 │
│  19.9 │
│  21.8 │
└───────┘

Without confidence interval:

SELECT studentTTestOneSample()(value, 20.0) FROM t;
-- or simply
SELECT studentTTestOneSample(value, 20.0) FROM t;

With confidence interval (95%):

SELECT studentTTestOneSample(0.95)(value, 20.0) FROM t;

See Also

studentTTestOneSample

Introduced in: v25.10

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 are nan).
  • Constant or near-constant input will also return nan due 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

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;