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

> 2つの母集団の標本にWelchのt検定を適用します。

# welchTTest

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

導入バージョン: v21.1.0

2 つの母集団から得られたサンプルに対して、[Welch の t 検定](https://en.wikipedia.org/wiki/Welch%27s_t-test)を適用します。

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

**構文**

```sql theme={null}
welchTTest([confidence_level])(sample_data, sample_index)
```

**パラメータ**

* `confidence_level` — 任意。信頼区間の計算に使用する信頼水準。[`Float`](/ja/reference/data-types/float)

**引数**

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

**戻り値**

2 つまたは 4 つの要素を持つ Tuple を返します (任意の `confidence_level` が指定されている場合) 。内容は、計算された t 統計量、計算された p 値、さらに必要に応じて計算された信頼区間の下限と上限です。[`Tuple(Float64, Float64)`](/ja/reference/data-types/tuple) または [`Tuple(Float64, Float64, Float64, Float64)`](/ja/reference/data-types/tuple)

**例**

**基本的な Welch's t 検定**

```sql title=Query theme={null}
CREATE TABLE welch_ttest (sample_data Float64, sample_index UInt8) ENGINE = Memory;
INSERT INTO welch_ttest VALUES (20.3, 0), (22.1, 0), (21.9, 0), (18.9, 1), (20.3, 1), (19, 1);

SELECT welchTTest(sample_data, sample_index) FROM welch_ttest;
```

```response title=Response theme={null}
┌─welchTTest(sample_data, sample_index)──────┐
│ (2.7988719532211235, 0.051807360348581945) │
└────────────────────────────────────────────┘
```

**信頼水準付き**

```sql title=Query theme={null}
SELECT welchTTest(0.95)(sample_data, sample_index) FROM welch_ttest;
```

```response title=Response theme={null}
┌─welchTTest(0.95)(sample_data, sample_index)─────────────────────────────────────────┐
│ (2.7988719532211235, 0.05180736034858519, -0.026294346671631885, 4.092961013338302) │
└─────────────────────────────────────────────────────────────────────────────────────┘
```

**関連項目**

* [Welchのt検定](https://en.wikipedia.org/wiki/Welch%27s_t-test)
* [studentTTest 関数](/ja/reference/functions/aggregate-functions/studentTTest)
