Relational Data - Aggregate Functions - Reference - Studentttest

From FojiSoft Docs
Revision as of 18:44, 28 August 2024 by Chris.Hansen (talk | contribs) (Import ClickHouse Docs: Wed Aug 28 2024 14:44:05 GMT-0400 (Eastern Daylight Time))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Applies Student’s t-test to samples from two populations.

Syntax

studentTTest([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 with equal variances is assumed.

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.]
  • [calculated confidence-interval-high. Float64.]

Example

Input table:

┌─sample_data─┬─sample_index─┐
│        20.3 │            0 │
│        21.1 │            0 │
│        21.9 │            1 │
│        21.7 │            0 │
│        19.9 │            1 │
│        21.8 │            1 │
└─────────────┴──────────────┘

Query:

SELECT studentTTest(sample_data, sample_index) FROM student_ttest;

Result:

┌─studentTTest(sample_data, sample_index)───┐
│ (-0.21739130434783777,0.8385421208415731) │
└───────────────────────────────────────────┘

See Also