## STATS_MW_TEST

Syntax

stats_mw_test::= Description of the illustration stats_mw_test.gif

Purpose

A Mann Whitney test compares two independent samples to test the null hypothesis that two populations have the same distribution function against the alternative hypothesis that the two distribution functions are different.

The `STATS_MW_TEST` does not assume that the differences between the samples are normally distributed, as do the `STATS_T_TEST_`* functions. This function takes three arguments and a return value of type `VARCHAR2`. `expr1` classifies the data into groups. `expr2` contains the values for each of the groups. The function returns one value, determined by the third argument. If you omit the third argument, the default is `TWO_SIDED_SIG`. The meaning of the return values is shown in the table that follows.

Table 7-7 STATS_MW_TEST Return Values

Return Value Meaning
`STATISTIC` The observed value of Z
`U_STATISTIC` The observed value of U
`ONE_SIDED_SIG` One-tailed significance of Z
`TWO_SIDED_SIG` Two-tailed significance of Z

`STATS_MW_TEST` computes the probability that the samples are from the same distribution by checking the differences in the sums of the ranks of the values. If the samples come from the same distribution, then the sums should be close in value.

STATS_MW_TEST Example

Using the Mann Whitney test, the following example determines whether the distribution of sales between men and women is due to chance:

```SELECT STATS_MW_TEST
(cust_gender, amount_sold, 'STATISTIC') z_statistic,
STATS_MW_TEST
(cust_gender, amount_sold, 'ONE_SIDED_SIG') one_sided_p_value
FROM sh.customers c, sh.sales s
WHERE c.cust_id = s.cust_id;

Z_STATISTIC ONE_SIDED_P_VALUE
----------- -----------------
-1.4011509        .080584471

```