4.5

4.5 | 3 ratings Rate this file 112 downloads (last 30 days) File Size: 3.83 KB File ID: #14807

AnDartest

by Antonio Trujillo-Ortiz

 

27 Apr 2007 (Updated 01 Aug 2007)

Code covered by BSD License  

Anderson-Darling test for assessing normality of a sample data.

Download Now | Watch this File

File Information
Description

The Anderson-Darling test (Anderson and Darling, 1952) is used to test if a sample of data comes from a specific distribution. It is a modification of the Kolmogorov-Smirnov (K-S) test and gives more weight to the tails than the K-S test. The K-S test is distribution free in the sense that the critical values do not depend on the specific distribution being tested.

The Anderson-Darling test makes use of the specific distribution in calculating critical values. This has the advantage of allowing a more sensitive test and the disadvantage that critical values must be calculated for each distribution.

The Anderson-Darling test is only available for a few specific distributions. The test is calculated as:
              
AD2 = integral{[F_o(x)-F_t(x)]^2/[F_t(x)(1-F_t(x)0]}dF_t(x)

AD2a = AD2*a

Note that for a given distribution, the Anderson-Darling statistic may be multiplied by a constant, a (which usually depends on the sample size, n). These constants are given in the various papers by Stephens (1974, 1977a, 1977b, 1979, 1986). This is what should be compared against the critical values. Also, be aware that different constants (and therefore critical values) have been published. You just need to be aware of what constant was used for a given set of critical values (the needed constant is typically
given with the critical values).

The critical values for the Anderson-Darling test are dependent on the specific distribution that is being tested. Tabulated values and formulas have been published for a few specific distributions (normal, lognormal, exponential, Weibull, logistic, extreme value type 1). The test is a one-sided test and the hypothesis that the distribution is of a specific form is rejected if the test statistic, AD2a, is greater than the critical value.

Here, we develop the m-file for detecting departure from normality. It is one of the most powerful statistics for test this.

Input:
x - data vector
alpha - significance level (default = 0.05)

Output:
- Complete Anderson-Darling normality test

Required Products Statistics Toolbox
MATLAB release MATLAB 7 (R14)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (4)
22 Oct 2008 Berrak Dag  
15 Jan 2009 Michael Jordan  
26 Jan 2009 Michael Jordan  
21 Jul 2009 Jalil Kianfar

Thanks a lot for this useful function, when I was using the functions this error occurred:

When the answer is “The sampled population is not normally distributed” this error happens:

Error in ==> AnDartest at 111
switch nargin

??? Output argument "AnDartest" (and maybe others) not assigned during call to "…\MATLAB\AnDartest.m (AnDartest)".

Please login to add a comment or rating.
Updates
30 Apr 2007

It was added an appropriate format to cite this file.

01 Aug 2007

Text was improved.

Tag Activity for this File
Tag Applied By Date/Time
statistics Antonio Trujillo-Ortiz 22 Oct 2008 09:10:49
probability Antonio Trujillo-Ortiz 22 Oct 2008 09:10:49
normality test Antonio Trujillo-Ortiz 22 Oct 2008 09:10:49
andersondarling test Antonio Trujillo-Ortiz 22 Oct 2008 09:10:49
assessing normality Cristina McIntire 05 Feb 2009 14:21:15
data Cristina McIntire 05 Feb 2009 14:21:15
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com