**8796** **TWOING INDEX**

4. Greenfield, C. C. and Tam, S. M. (1976).

**J. R. Statist. Soc. A, 139, 96–103.**

*5. Macarthur, E. W. (1983). J. R. Statist. Soc. A,*
**146, 85–86.**

* 6. Nour, EI-S. (1982). J. R. Statist. Soc. A, 145,*
106–116.

See also LOG-LINEARMODELS INCONTINGENCYTABLES; TETRACHORICCORRELATIONCOEFFICIENT; and TWO-BY-TWO(2× 2) TABLES.

**TWOING INDEX**

An index of ‘‘distinctiveness’’ or diversity∗
used in some recursive partitioning∗
proce-dures. If a node is split into two nodes, say
*L and R, in proportions pL: pR(pL+ pR*= 1)
such that the proportion of items from class
*(j) in L(R) is PjL(PjR), the twoing index of the*
split is
1
4*pLpR*
*j|pjL− pjR*|
2
*.*

The greater the index, the more effective the split.

See also DIVERSITYINDICESand RECURSIVEPARTITIONING.

**TWO-PHASE SAMPLING.**

See
SURVEYSAMPLING

**TWO-SAMPLE MATCHING TEST**

The two-sample matching test is a procedure
to test whether two independent samples
come from the same continuous distribution
*or not. Let X and Y be independent*ran-dom variables with continuous cumulative

*distribution functions F and G respectively,*

*and let X(k)*

*and Y(k)*, 1

*k n, be the order*

statistics∗ of independent random samples
*from F and G. In inference with two *
sam-ples, one issue of interest is whether the two
samples indeed come from two different
pop-ulations or not. The standard procedure is to
*test the null hypothesis H*0*: G= F.*

Since comparison of two samples is a fundamental topic of statistics, interest in

testing the above hypothesis goes back to
the late thirties. Smirnov [7] proposed the
test statistic sup* _{−∞<x<∞}|Fn(x)− Gm(x)| for*
arbitrary sample sizes against the

*alterna-tive H*1

*: G= F, where Fn(x) and Gm(x) are*

*the empirical distribution functions of F and*

*G respectively (see K*OLMOGOROV–SMIRNOV

STATISTICS). The distribution of this test statistic and generalizations of it were studied later by several authors, including Tak ´acs [8], where related references can also be found.

However, if the main concern is a
spe-cific alternative, other nonparametric tests
with greater power are preferable. In
particu-lar, the well-known nonparametric tests such
as the Wilcoxon, Mann–Whitney∗, and von
Mises tests are developed against location
*shift alternatives that assume that G(x)*=
*F(x− ), and the corresponding alternatives*
*H*1*: > (<,*=)0 then induce a stochastic

*ordering between F and G [2,4].*

The two-sample matching test to be
described here is appropriate for any general
*alternative H*1*: F(x)= G(x). In this entry, the*

exact distribution and the moments of the test statistic are presented and the limit-ing distribution is provided, together with the result that the test is consistent against a general alternative. More details are pre-sented in refs. 3, 6.

Assume without loss of generality that the
*distributions F and G are concentrated on the*
*unit interval [0, 1], and that F(x)= x, 0 x *
1. The test considered in Rao and Tiwari [5]
and G ¨urler and Siddiqui [1] is based on the
*number of matches between the order *
*statis-tics X(k)and Y(k), k= 1, . . . , n, from F and G*

*respectively. For the event Ak*, a match occurs
*if X(k)∈ (Y(k*−1)*, Y(k)] for any k, 1 k n, with*

*Y*(0)*= 0. The matching test statistic is then*

*Sn*=
*n*

*k*=1* Ik, where Ik* is the indicator of

*Ak. Sn*is a special case of a more gen-eral class of statistics considered in ref. 8. Later, Rao and Tiwari [5] provided a

*sim-pler proof for the special case of Sn*defined

*above. Let P*0

*and P*1be the probability

*mea-sures, and E*0*and E*1the expectations, under

*H*0 *and H*1*, respectively. Clearly, for k* 1,

*P*0*(Sn k) P*1*(Sn k). Hence, for a *
*signifi-cance level α, 0 < α < 1, the critical region for*
*testing H*0*against H*1*is of the form Sn kn,α*

**TWO-SAMPLE MATCHING TEST** **8797**
**Table 1.**
*X(i)* *Y(i)*
0.094 0.0039
0.168 0.0041
0.229 0.0064
0.265 0.0116
0.384 0.0706
0.460 0.0997
0.482 0.1028
0.511 0.1069
0.523 0.5792
0.710 0.6155

*where kn,α* *is the largest integer k such that*
*P*0*(Sn k) α.*

**Example. Suppose an X-sample of size 10**

is observed from a uniform distribution on
*(0, 1), and a Y-sample of the same size*
is observed from a beta distribution∗ with
*parameters α= 0.5 and β = 1.5, with the*
*order statistics shown in Table 1. Then Sn*=
1, indicating that there is only one
match-ing between the order statistics of the two
*samples at X*(9)*= 0.523, which lies between*

0.1069 and 0.5792. We will see shortly that,
according to the asymptotic distribution of
*Sn, we reject H*0for this particular sample.

**DISTRIBUTION, MEAN, AND VARIANCE OF**

**S****N**

*An exact expression for P*0*(Sn k), given*
in ref. 8, uses lattice-path counting
meth-ods. The alternative proof in ref. 5 is based
*on the number of crossings in the *
Kol-mogorov–Smirnov statistics. The exact
*dis-tribution of Sn* *under H*0*, for k= 1, . . . , n, is*

given by
*P(Sn k) =*
*2n*
*n+ k*
*2n*
*n*
*.* (1)

*The mean and the variance of Sn*, under the
*hypothesis H*0*: F= G, are given by*

*E[Sn*]=
2*2n*−1
*2n*
*n*
−1
2,
*Var[Sn*]*= n +*
1
4 −
2*4n*−2
*2n*
*n*
2*.*

*For small n, the exact distribution of Sn*can
be tabulated using (1). However, when the
sample size is large, it is desirable to exhibit
the rejection region in a simpler form for
practical purposes, via the limiting
*distri-bution of Sn*. Under the null hypothesis of
*identical distributions for X and Y, and for*
*x > 0 [1],*

lim

*n*→∞*P*0*(n−1/2Sn x) = e−x*

2

*.*

From this result, approximate critical regions
*of the test can be found. For a size-α test, we*
*reject if Sn kn,α, where kn,α= [−n ln(1 −*
*α)]1/2. Then, if we fix α= 0.05, for n = 5,*
*10, 15, 20, 30, the kn,α*-values are obtained
*as kn,0.05= 0.506, 0.716, 0.877, 1.01, 1.24*
respectively. In the example above, since
*S*10*= 1 > 0.716, we reject H*0.

**Consistency**

*A test is consistent if its power tends to*
*one as n tends to infinity, against a fixed*
alternative. If the measure of the interval
*on which F(x) and G(x) do not cross each*
other is one (that is, if they cross each other
only at countably many points), then the test
*based on Sn*is consistent for any significance
*level α, 0 < α < 1 [1]. This result *
guaran-tees that as the sample size increases, the
power of the matching test converges to one
against a general alternative and therefore
the test is consistent. However, the result
does not indicate anything about the
small-sample behavior of the test and the rate of
convergence for the power.

**REFERENCES**

1. G ¨urler, ¨U. and Siddiqui, M. M. (1996). On the
*consistency of a two-sample matching test. *

**Non-parametric Statist., 7, 69–73.**

2. H ´ajek, J. and ˇ*Sid ´ak, Z. (1967). Theory of Ranked*

*Tests. Academic Press, New York.*

3. Khidr, A. M. (1981). Matching of order
*statis-tics with intervals. Indian J. Pure Appl. Math.,*
**12, 1402–1407.**

*4. Randles, R. H. and Wolfe, D. A. (1979). *

*Intro-duction to the Theory of Nonparametric *
*Statis-tics. Wiley, New York.*

5. Rao, J. S. and Tiwari, R. C. (1983). One- and
*two-sample match statistics. Statist. Probab.*

**8798** **TWO-SAMPLE PROBLEM**

6. Siddiqui, M. M. (1982). The consistency of a
* matching test. J. Statist. Plann. Inference, 6,*
227–233.

7. Smirnov, N. V. (1939). On the estimation of
the discrepancy between empirical curves of
distribution for two independent samples. (In
* Russian.) Bull. Math. Univ. Moscow A, 2, 3–14.*
8. Tak ´acs, L. (1971). On the comparison of two

*empirical distribution functions. Ann. Math.*

**Statist., 42, 1157–1166.**

See also EMPIRICALDISTRIBUTIONFUNCTION(EDF) STATISTICS; GOODNESS-OF-FITDISTRIBUTION, TAK ´ACS; KOLMOGOROV–SMIRNOVSTATISTICS; and ORDER STATISTICS.

¨

ULK ¨UGURLER¨

**TWO-SAMPLE PROBLEM.**

See
LOCATIONTESTS

**TWO-SAMPLE PROBLEM, **

**BAUM-GARTNER–WEISS–SCHINDLER**

**TEST**

Tests that two independent samples

*X*1*, . . . , Xmand Y*1*, . . . , Ymbelong to the same*
*continuous population (two-sample problem)*
abound in the statistical literature. Among
them, the Kolmogorov-Smirnov* test, the
Cram´er-von Mises* test, and the
Mann-Whitney–Wilcoxon* test are perhaps the
most popular in applications.

These tests are based on comparisons of
the two empirical* distribution functions or
edfs
*Fn(x)*=
0 *for x < X*1,
*i/n for Xi< x < Xi*+1
1 *for x > Xn*,

*and Fm(x), defined analogously for the *
*sam-ple Y*1*, Y*2*, . . . , Ym*. (Observations here are
ordered in increasing order of magnitude.)

The Kolmogorov-Smirnov test uses the
maximum of *|Fn(x)− Fm(x)|, the Wilcoxon*
*test utilizes the integral of [Fn(x)− Fm(x)],*
and the Cram´er-von Mises test employs the
*squared norm of [Fn(x)− Fm(x)] as test *
val-ues.

The Baumgartner–Weiss–Schindler

(BWS) test [2] uses the squared norm of
*the difference [Fn(x)− Fm(x)] weighted by*

its variance, an idea borrowed from the Anderson-Darling test for the one-sample problem [1].

Specifically, for testing the null hypothesis
that both samples are drawn from the same
population with continuous but unknown cdf
*F(x), the integral transformation*

*Z= F(X)*

*is introduced, which results in Z being almost*
*surely uniformly distributed on [0,1] if X has*
*the cdf F(x). Applying this transformation to*
the two sets of data, we arrive at the edfs

ˆ

*Fn(z) and ˆFm(z). The difference ˆFn(z)− ˆFm(z)*
*is weighted by [z(1− z)]*−1, yielding a test
value
*˜B =* *mn*
*m+ n*
1
0
*[z(1− z)]*−1( ˆ*Fn(z)− ˆFm(z))*2*dz*
(1)
*Since F(x) is unknown, BWS 2 propose to*
approximate Equation (1) using ranks. The
*rank Gi* *(resp. Hi) of each element Xi* (resp.
*Yj*) is defined as the number of data values
*in both samples smaller than or equal to Xi*
*(resp. Yj*). Then ˜*B is approximated by*

*BX* =
1
*n*
*n*
*i*=1
*(Gi*−*m+n _{n}*

*i)*2

*i*

*n*+1(1−

*i*

*n*+1)

*m(m+n)*

*n*(2) or by

*BY*= 1

*m*

*m*

*j*=1

*(Hj*−

*m*2

_{m}+nj)*j*

*m*+1(1−

*m*+1

*j*)

*n(mm+n)*(3)

*and new test statistic B is defined to be*
*B= (BX+ BY)/2.*

The processes in Equations (2) and (3)
converge to a standard Brownian bridge* as
*n, m→ ∞ and n/m → a (where a is a finite*
constant). Applying the Anderson-Darling
technique [1], BWS derive the asymptotic
*distribution of B to be*
*(b)*= lim
*n,m*→∞*Pr(B < b)*
=
*π*
2
1
*b*
∞
*j*=0
−1
2
*j*
*(4j*+ 1)
1
0
1
*r*3_{(1}* _{− r)}*
× exp

*rb*8 −

*π*2

_{(4j}_{+ 1)}2

*8rb*

*dr*,