> ## 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つの母集団のサンプルに対して、マン・ホイットニーの順位検定を適用します。

# mannWhitneyUTest

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

導入バージョン: v21.1.0

2 つの母集団から得られたサンプルに対して、マン・ホイットニーの順位検定を適用します。

両方のサンプルの値は `sample_data` カラムに格納されます。
`sample_index` が 0 の場合、その行の値は 1 つ目の母集団のサンプルに属します。
それ以外の場合は、2 つ目の母集団のサンプルに属します。
帰無仮説は、2 つの母集団が確率的に等しいことです。
片側仮説の検定も可能です。
この検定では、データが正規分布に従うことを仮定しません。

**構文**

```sql theme={null}
mannWhitneyUTest[(alternative[, continuity_correction])](sample_data, sample_index)
```

**パラメータ**

* `alternative` — 任意。対立仮説。'two-sided' (デフォルト) ：2つの母集団は確率的に同等ではありません。'greater'：1番目のサンプルの値は、2番目のサンプルの値より確率的に大きくなります。'less'：1番目のサンプルの値は、2番目のサンプルの値より確率的に小さくなります。 [`String`](/ja/reference/data-types/string)
* `continuity_correction` — 任意。0 以外の場合、p 値の正規近似に連続性補正が適用されます。デフォルト値は 1 です。 [`UInt64`](/ja/reference/data-types/int-uint)

**引数**

* `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)

**戻り値**

計算された U 統計量と p 値の 2 つの要素を持つタプルを返します。 [`Tuple(Float64, Float64)`](/ja/reference/data-types/tuple)

**例**

**Mann-Whitney の U 検定の例**

```sql title=Query theme={null}
CREATE TABLE mww_ttest (sample_data Float64, sample_index UInt8) ENGINE = Memory;
INSERT INTO mww_ttest VALUES (10, 0), (11, 0), (12, 0), (1, 1), (2, 1), (3, 1);

SELECT mannWhitneyUTest('greater')(sample_data, sample_index) FROM mww_ttest;
```

```response title=Response theme={null}
┌─mannWhitneyUTest('greater')(sample_data, sample_index)─┐
│ (9,0.04042779918503192)                                │
└────────────────────────────────────────────────────────┘
```

**関連項目**

* [マン＝ホイットニーのU検定](https://en.wikipedia.org/wiki/Mann%E2%80%93Whitney_U_test)
* [確率順序](https://en.wikipedia.org/wiki/Stochastic_ordering)
