Statistics: bartlett_test

### Function Reference: `bartlett_test`

statistics: h = bartlett_test (x)
statistics: h = bartlett_test (x, group)
statistics: h = bartlett_test (x, alpha)
statistics: h = bartlett_test (x, group, alpha)
statistics: [h, pval] = bartlett_test (…)
statistics: [h, pval, chisq] = bartlett_test (…)
statistics: [h, pval, chisq, df] = bartlett_test (…)

Perform a Bartlett test for the homogeneity of variances.

Under the null hypothesis of equal variances, the test statistic chisq approximately follows a chi-square distribution with df degrees of freedom.

The p-value (1 minus the CDF of this distribution at chisq) is returned in pval. h = 1 if the null hypothesis is rejected at the significance level of alpha. Otherwise h = 0.

Input Arguments:

- x contains the data and it can either be a vector or matrix. If x is a matrix, then each column is treated as a separate group. If x is a vector, then the group argument is mandatory. NaN values are omitted.
- group contains the names for each group. If x is a vector, then group must be a vector of the same length, or a string array or cell array of strings with one row for each element of x. x values corresponding to the same value of group are placed in the same group. If x is a matrix, then group can either be a cell array of strings of a character array, with one row per column of x in the same way it is used in `anova1` function. If x is a matrix, then group can be omitted either by entering an empty array ([]) or by parsing only alpha as a second argument (if required to change its default value).
- alpha is the statistical significance value at which the null hypothesis is rejected. Its default value is 0.05 and it can be parsed either as a second argument (when group is omitted) or as a third argument.

See also: levene_test, vartest2, vartestn

Source Code: bartlett_test