def wilcoxon(x, y=None, zero_method="<STR_LIT>", correction=False):
if zero_method not in ["<STR_LIT>", "<STR_LIT>", "<STR_LIT>"]:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if y is None:<EOL><INDENT>d = x<EOL><DEDENT>else:<EOL><INDENT>x, y = map(asarray, (x, y))<EOL>if len(x) != len(y):<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>d = x-y<EOL><DEDENT>if zero_method == "<STR_LIT>":<EOL><INDENT>d = compress(not_equal(d, <NUM_LIT:0>), d, axis=-<NUM_LIT:1>)  <EOL><DEDENT>count = len(d)<EOL>if (count < <NUM_LIT:10>):<EOL><INDENT>warnings.warn("<STR_LIT>")<EOL><DEDENT>r = stats.rankdata(abs(d))<EOL>r_plus = sum((d > <NUM_LIT:0>) * r, axis=<NUM_LIT:0>)<EOL>r_minus = sum((d < <NUM_LIT:0>) * r, axis=<NUM_LIT:0>)<EOL>if zero_method == "<STR_LIT>":<EOL><INDENT>r_zero = sum((d == <NUM_LIT:0>) * r, axis=<NUM_LIT:0>)<EOL>r_plus += r_zero / <NUM_LIT><EOL>r_minus += r_zero / <NUM_LIT><EOL><DEDENT>T = min(r_plus, r_minus)<EOL>mn = count*(count + <NUM_LIT:1.>) * <NUM_LIT><EOL>se = count*(count + <NUM_LIT:1.>) * (<NUM_LIT> * count + <NUM_LIT:1.>)<EOL>if zero_method == "<STR_LIT>":<EOL><INDENT>r = r[d != <NUM_LIT:0>]<EOL><DEDENT>replist, repnum = find_repeats(r)<EOL>if repnum.size != <NUM_LIT:0>:<EOL><INDENT>se -= <NUM_LIT:0.5> * (repnum * (repnum * repnum - <NUM_LIT:1>)).sum()<EOL><DEDENT>se = sqrt(se / <NUM_LIT>)<EOL>correction = <NUM_LIT:0.5> * int(bool(correction)) * np.sign(T - mn)<EOL>z = (T - mn - correction) / se<EOL>prob = <NUM_LIT> * distributions.norm.sf(abs(z))<EOL>return T, prob<EOL>
Calculate the Wilcoxon signed-rank test.

The Wilcoxon signed-rank test tests the null hypothesis that two
related paired samples come from the same distribution. In particular,
it tests whether the distribution of the differences x - y is symmetric
about zero. It is a non-parametric version of the paired T-test.

Parameters
----------
x : array_like
    The first set of measurements.
y : array_like, optional
    The second set of measurements.  If `y` is not given, then the `x`
    array is considered to be the differences between the two sets of
    measurements.
zero_method : string, {"pratt", "wilcox", "zsplit"}, optional
    "pratt":
        Pratt treatment: includes zero-differences in the ranking process
        (more conservative)
    "wilcox":
        Wilcox treatment: discards all zero-differences
    "zsplit":
        Zero rank split: just like Pratt, but spliting the zero rank
        between positive and negative ones
correction : bool, optional
    If True, apply continuity correction by adjusting the Wilcoxon rank
    statistic by 0.5 towards the mean value when computing the
    z-statistic.  Default is False.

Returns
-------
T : float
    The sum of the ranks of the differences above or below zero, whichever
    is smaller.
p-value : float
    The two-sided p-value for the test.

Notes
-----
Because the normal approximation is used for the calculations, the
samples used should be large.  A typical rule is to require that
n > 20.

References
----------
.. [1] http://en.wikipedia.org/wiki/Wilcoxon_signed-rank_test