def bartlett(*args):
k = len(args)<EOL>if k < <NUM_LIT:2>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>Ni = zeros(k)<EOL>ssq = zeros(k,'<STR_LIT:d>')<EOL>for j in range(k):<EOL><INDENT>Ni[j] = len(args[j])<EOL>ssq[j] = np.var(args[j], ddof=<NUM_LIT:1>)<EOL><DEDENT>Ntot = sum(Ni,axis=<NUM_LIT:0>)<EOL>spsq = sum((Ni-<NUM_LIT:1>)*ssq,axis=<NUM_LIT:0>)/(<NUM_LIT:1.0>*(Ntot-k))<EOL>numer = (Ntot*<NUM_LIT:1.0>-k)*log(spsq) - sum((Ni-<NUM_LIT:1.0>)*log(ssq),axis=<NUM_LIT:0>)<EOL>denom = <NUM_LIT:1.0> + (<NUM_LIT:1.0>/(<NUM_LIT:3>*(k-<NUM_LIT:1>)))*((sum(<NUM_LIT:1.0>/(Ni-<NUM_LIT:1.0>),axis=<NUM_LIT:0>))-<NUM_LIT:1.0>/(Ntot-k))<EOL>T = numer / denom<EOL>pval = distributions.chi2.sf(T,k-<NUM_LIT:1>)  <EOL>return T, pval<EOL>
Perform Bartlett's test for equal variances

Bartlett's test tests the null hypothesis that all input samples
are from populations with equal variances.  For samples
from significantly non-normal populations, Levene's test
`levene` is more robust.

Parameters
----------
sample1, sample2,... : array_like
    arrays of sample data.  May be different lengths.

Returns
-------
T : float
    The test statistic.
p-value : float
    The p-value of the test.

References
----------
.. [1]  http://www.itl.nist.gov/div898/handbook/eda/section3/eda357.htm

.. [2]  Snedecor, George W. and Cochran, William G. (1989), Statistical
          Methods, Eighth Edition, Iowa State University Press.