NMath User's Guide

45.4 One Sample Anderson-Darling Test (.NET, C#, CSharp, VB, Visual Basic, F#)

Class OneSampleAndersonDarlingTest performs a Anderson-Darling test of the distribution of one sample. An Anderson-Darling test compares the distribution of a given sample to normal distribution function (CDF). The alternative hypothesis that the data do not have a normal distribution.

Code Example – C# Anderson-Darling test

```int n = 100;
```
```var data = new DoubleVector( n, new RandGenGamma( 23.0 ) );
```
```var test = new OneSampleAndersonDarlingTest( data );

```

```Console.WriteLine( "statistic = " + test.Statistic );
```
```Console.WriteLine( "p-value = " + test.P );
```
```Console.WriteLine( "alpha = " + test.Alpha );
```
```Console.WriteLine( "reject the null hypothesis? " + test.Reject);
```

Code Example – VB Anderson-Darling test

```Dim N As Integer = 100
```
```Dim Data As New DoubleVector(N, New RandGenGamma(23.0))
```
```Dim Test As New OneSampleAndersonDarlingTest(Data)

```

```Console.WriteLine("statistic = " & Test.Statistic)
```
```Console.WriteLine("p-value = " & Test.P)
```
```Console.WriteLine("alpha = " & Test.Alpha)
```
```Console.WriteLine("reject the null hypothesis? " & Test.Reject)
```

Top

Top