メインコンテンツへスキップ
メインコンテンツへスキップ

meanZTest

meanZTest

導入: v22.2

2つの母集団からのサンプルに対して平均のZ検定を適用します。

両方のサンプルの値は sample_data カラムに含まれます。 sample_index が 0 の場合、その行の値は最初の母集団からのサンプルに属します。 それ以外の場合は2番目の母集団からのサンプルに属します。 帰無仮説は、母集団の平均が等しいというものです。 正規分布を仮定します。 母集団間で分散は等しくない場合があり、各分散は既知であるとします。

構文

meanZTest(population_variance_x, population_variance_y, confidence_level)(sample_data, sample_index)

パラメータ

  • population_variance_x — 母集団 x の分散。Float*
  • population_variance_y — 母集団 y の分散。Float*
  • confidence_level — 信頼区間を計算する際の信頼水準。Float*

引数

  • sample_data — サンプルデータ。(U)Int* または Float* または Decimal
  • sample_index — サンプルインデックス。(U)Int*

戻り値

4 要素からなるタプルを返します。計算された z 統計量、計算された p 値、計算された信頼区間の下限、計算された信頼区間の上限。Tuple(Float64, Float64, Float64, Float64)

平均 Z 検定の例

CREATE TABLE mean_ztest (sample_data Float64, sample_index UInt8) ENGINE = Memory;
INSERT INTO mean_ztest VALUES (20.3, 0), (21.9, 0), (22.1, 0), (18.9, 1), (19, 1), (20.3, 1);

SELECT meanZTest(0.7, 0.45, 0.95)(sample_data, sample_index) FROM mean_ztest;
┌─meanZTest(0.7, 0.45, 0.95)(sample_data, sample_index)───────────────────────────────┐
│ (3.2841296025548123, 0.0010229786769086013, 0.8198428246768334, 3.2468238419898365) │
└─────────────────────────────────────────────────────────────────────────────────────┘