Skip to main content

meanZTest

Applies mean z-test to samples from two populations.

Syntax

meanZTest(population_variance_x, population_variance_y, 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 and the variances are known.

Arguments

Parameters

  • population_variance_x β€” Variance for population x. Float.
  • population_variance_y β€” Variance for population y. Float.
  • confidence_level β€” Confidence level in order to calculate confidence intervals. Float.

Returned values

Tuple with four elements:

  • 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.9 β”‚ 0 β”‚
β”‚ 22.1 β”‚ 0 β”‚
β”‚ 18.9 β”‚ 1 β”‚
β”‚ 19 β”‚ 1 β”‚
β”‚ 20.3 β”‚ 1 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Query:

SELECT meanZTest(0.7, 0.45, 0.95)(sample_data, sample_index) FROM mean_ztest

Result:

β”Œβ”€meanZTest(0.7, 0.45, 0.95)(sample_data, sample_index)────────────────────────────┐
β”‚ (3.2841296025548123,0.0010229786769086013,0.8198428246768334,3.2468238419898365) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Original article