Skip to main content

welchTTest

Applies Welch's t-test to samples from two populations.

Syntax

welchTTest([confidence_level])(sample_data, sample_index)

Values of both samples are in the sample_data column. If sample_index equals to 0 then the value in that row belongs to the sample from the first population. Otherwise it belongs to the sample from the second population. The null hypothesis is that means of populations are equal. Normal distribution is assumed. Populations may have unequal variance.

Arguments

Parameters

  • confidence_level β€” Confidence level in order to calculate confidence intervals. Float.

Returned values

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

  • calculated t-statistic. Float64.
  • calculated p-value. Float64.
  • [calculated confidence-interval-low.][Float64](/docs/en/sql-reference/data-types/float).
  • [calculated confidence-interval-high.][Float64](/docs/en/sql-reference/data-types/float).

Example

Input table:

β”Œβ”€sample_data─┬─sample_index─┐
β”‚ 20.3 β”‚ 0 β”‚
β”‚ 22.1 β”‚ 0 β”‚
β”‚ 21.9 β”‚ 0 β”‚
β”‚ 18.9 β”‚ 1 β”‚
β”‚ 20.3 β”‚ 1 β”‚
β”‚ 19 β”‚ 1 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Query:

SELECT welchTTest(sample_data, sample_index) FROM welch_ttest;

Result:

β”Œβ”€welchTTest(sample_data, sample_index)─────┐
β”‚ (2.7988719532211235,0.051807360348581945) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

See Also

Original article