> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-8c05c8a2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> 2つの母集団から抽出したサンプルに対して平均値の z 検定を適用します。

# meanZTest

<div id="meanZTest">
  ## meanZTest
</div>

導入バージョン: v22.2.0

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

両方のサンプルの値は `sample_data` カラムに格納されます。
`sample_index` が 0 の場合、その行の値は 1 つ目の母集団のサンプルに属します。
それ以外の場合は、2 つ目の母集団のサンプルに属します。
帰無仮説は、母集団の平均が等しいことです。
正規分布を仮定します。
母集団の分散は等しくない場合があり、分散は既知です。

**構文**

```sql theme={null}
meanZTest(population_variance_x, population_variance_y, confidence_level)(sample_data, sample_index)
```

**パラメータ**

* `population_variance_x` — 母集団 x の分散。[`Float*`](/ja/reference/data-types/float)
* `population_variance_y` — 母集団 y の分散。[`Float*`](/ja/reference/data-types/float)
* `confidence_level` — 信頼区間の計算に使用する信頼水準。[`Float*`](/ja/reference/data-types/float)

**引数**

* `sample_data` — サンプルデータ。[`(U)Int*`](/ja/reference/data-types/int-uint) または [`Float*`](/ja/reference/data-types/float) または [`Decimal`](/ja/reference/data-types/decimal)
* `sample_index` — サンプルインデックス。[`(U)Int*`](/ja/reference/data-types/int-uint)

**戻り値**

4 つの要素を持つタプルを返します: 計算された z 統計量、計算された p 値、計算された信頼区間の下限、計算された信頼区間の上限。[`Tuple(Float64, Float64, Float64, Float64)`](/ja/reference/data-types/tuple)

**例**

**平均の Z 検定の例**

```sql title=Query theme={null}
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;
```

```response title=Response theme={null}
┌─meanZTest(0.7, 0.45, 0.95)(sample_data, sample_index)───────────────────────────────┐
│ (3.2841296025548123, 0.0010229786769086013, 0.8198428246768334, 3.2468238419898365) │
└─────────────────────────────────────────────────────────────────────────────────────┘
```
