def _anderson_ksamp_right(samples, Z, Zstar, k, n, N):
A2kN = <NUM_LIT:0.><EOL>lj = Z.searchsorted(Zstar[:-<NUM_LIT:1>], '<STR_LIT:right>') - Z.searchsorted(Zstar[:-<NUM_LIT:1>],<EOL>'<STR_LIT:left>')<EOL>Bj = lj.cumsum()<EOL>for i in arange(<NUM_LIT:0>, k):<EOL><INDENT>s = np.sort(samples[i])<EOL>Mij = s.searchsorted(Zstar[:-<NUM_LIT:1>], side='<STR_LIT:right>')<EOL>inner = lj / float(N) * (N * Mij - Bj * n[i])**<NUM_LIT:2> / (Bj * (N - Bj))<EOL>A2kN += inner.sum() / n[i]<EOL><DEDENT>return A2kN<EOL>
Compute A2akN equation 6 of Scholz & Stephens.

Parameters
----------
samples : sequence of 1-D array_like
    Array of sample arrays.
Z : array_like
    Sorted array of all observations.
Zstar : array_like
    Sorted array of unique observations.
k : int
    Number of samples.
n : array_like
    Number of observations in each sample.
N : int
    Total number of observations.

Returns
-------
A2KN : float
    The A2KN statistics of Scholz and Stephens 1987.