| Products & Services | Industries | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Statistics Toolbox |
| Contents | Index |
| Learn more about Statistics Toolbox |
h = ansaribradley(x,y)
h = ansaribradley(x,y,alpha)
h = ansaribradley(x,y,alpha,tail)
[h,p] = ansaribradley(...)
[h,p,stats] = ansaribradley(...)
[...] = ansaribradley(x,y,alpha,tail,exact)
[...] = ansaribradley(x,y,alpha,tail,exact,dim)
h = ansaribradley(x,y) performs an Ansari-Bradley test of the hypothesis that two independent samples, in the vectors x and y, come from the same distribution, against the alternative that they come from distributions that have the same median and shape but different dispersions (e.g. variances). The result is h = 0 if the null hypothesis of identical distributions cannot be rejected at the 5% significance level, or h = 1 if the null hypothesis can be rejected at the 5% level. x and y can have different lengths.
x and y can also be matrices or N-dimensional arrays. For matrices, ansaribradley performs separate tests along each column, and returns a vector of results. x and y must have the same number of columns. For N-dimensional arrays, ansaribradley works along the first nonsingleton dimension. x and y must have the same size along all the remaining dimensions.
h = ansaribradley(x,y,alpha) performs the test at the significance level (100*alpha), where alpha is a scalar.
h = ansaribradley(x,y,alpha,tail) performs the test against the alternative hypothesis specified by the string tail. tail is one of:
'both' — Two-tailed test (dispersion parameters are not equal)
'right' — Right-tailed test (dispersion of X is greater than dispersion of Y)
'left' — Left-tailed test (dispersion of X is less than dispersion of Y)
[h,p] = ansaribradley(...) returns the p-value, i.e., the probability of observing the given result, or one more extreme, by chance if the null hypothesis is true. Small values of p cast doubt on the validity of the null hypothesis.
[h,p,stats] = ansaribradley(...) returns a structure stats with the following fields:
'W' — Value of the test statistic W, which is the sum of the Ansari-Bradley ranks for the X sample
'Wstar' — Approximate normal statistic W*
[...] = ansaribradley(x,y,alpha,tail,exact) computes p using an exact calculation of the distribution of W with exact = 'on'. This can be time-consuming for large samples. exact = 'off' computes p using a normal approximation for the distribution of W*. The default if exact is empty is to use the exact calculation if N, the total number of rows in x and y, is 25 or less, and to use the normal approximation if N > 25. Pass in [] for alpha and tail to use their default values while specifying a value for exact. Note that N is computed before any NaN values (representing missing data) are removed.
[...] = ansaribradley(x,y,alpha,tail,exact,dim) works along dimension dim of x and y.
The Ansari-Bradley test is a nonparametric alternative to the two-sample F test of equal variances. It does not require the assumption that x and y come from normal distributions. The dispersion of a distribution is generally measured by its variance or standard deviation, but the Ansari-Bradley test can be used with samples from distributions that do not have finite variances.
The theory behind the Ansari-Bradley test requires that the groups have equal medians. Under that assumption and if the distributions in each group are continuous and identical, the test does not depend on the distributions in each group. If the groups do not have the same medians, the results may be misleading. Ansari and Bradley recommend subtracting the median in that case, but the distribution of the resulting test, under the null hypothesis, is no longer independent of the common distribution of x and y. If you want to perform the tests with medians subtracted, you should subtract the medians from x and y before calling ansaribradley.
Is the dispersion significantly different for two model years?
load carsmall
[h,p,stats] = ansaribradley(MPG(Model_Year==82),MPG(Model_Year==76))
h =
0
p =
0.8426
stats =
W: 526.9000
Wstar: 0.1986![]() | anovan | aoctool | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |