Bartlett's test - mauriceling/mauriceling.github.io GitHub Wiki

Purpose: To test whether the variances of 2 or more samples are equal.

Null hypothesis: Variances of all samples are equal.

Alternate hypothesis: At least one sample variance is not equal to the rest.

Note: Bartlett's test assumes that the samples are normally distributed. For non-normal samples, Fligner-Killeen test or Levene's test are more robust.

Code:

>>> from scipy import stats
>>> X1 = [9.07, 8.97, 6.41, 3.03, 1.19, 2.67, 2.81, 9.2]
>>> X2 = [3.82, 8.26, 5.99, 3.81, 1.07, 5.06, 5.66, 4.47]
>>> X3 = [8.46, 7.46, 4.48, 1.41, 3.16, 1.77, 5.33, 6.61]
>>> result = stats.bartlett(X1, X2, X3)
>>> print("Statistic = %.3f" % result[0])
Statistic = 1.521
>>> print("p-value = %.3f" % result[1])
p-value = 0.468

Reference

  1. Bartlett MS. 1937. Properties of Sufficiency and Statistical Tests. Proceedings of the Royal Society of London. Series A, Mathematical and Physical Sciences 160(901), 268-282.