In this post the Pascal Code to implement the Anderson-Darling normality test will be discussed, along with a set of sample runs compared to the results from Minitab Express statistical software. The complete set of formulas for calculating the Anderson-Darling Test statistic for Normality and associated P-Value are :

In case statistics is confusing to you, or what’s so important about this p-value let me try give some very quick background. For a normality test we assume that data comes from a normally distributed population, and try to prove it’s from one that is not. The p-value is the probability that I would be wrong if I said the data is not from a normal distribution. So if the p-value is small ( less than 0.05) I can assume the data does not come from a normally distributed set of data.

In the previous posts the work to determine the value of the CDF is discussed, now the test statistics can be calculated, A-Squared, A-Squared Prime, and the P-value.

The code block below is the implementation of the Asquared statistic.

Red arrow – is the FOR loop to do the summation over all values (NN) in the sample

Yellow Arrow – Call to the CDF lookup in STATAD.P

Blue Arrow – calculation for this data point

Green – Arrow – finishes the calculation after then summing is complete

With the A-Squared value A-squared Prime and the P-value can be calculated, the source code is shown in the two images below:

I validated my code with four sets of data which I also ran through Minitab Express (commercial stats program from Minitab inc.) and the results are shown below. While I was testing I also looked at the descriptive stats from earlier posts:

Here are the four sets of data (as a reminder, this is my daily weight over four weeks in March 2017) shown both in Minitab express and my STATS program.

Here are the results for all four sets of data, and except for some small round differences, all looks good.

As an side, we can not prove any of the four data sets do not come from a normal population, however 7 data points is a fairly small size sample.

Next on the agenda is adding the ability to load data sets from text files and some menu options, and then at least one graph or plot to take advantage of the graphics capabilities of the Atari 800 and Kyan Pascal.

### Like this:

Like Loading...

I’m looking for an implementation of the Anderson-Darling test in Delphi and wonder if you would offer any file download that would help to accomplish this.

LikeLike

What I have I’ve posted, it’s not a straight forward algorithm with table look ups for probability density function

LikeLike