Click or drag to resize
Accord.NET (logo)

AndersonDarlingTest Class

One-sample Anderson-Darling (AD) test.
Inheritance Hierarchy
SystemObject
  Accord.Statistics.TestingHypothesisTestAndersonDarlingDistribution
    Accord.Statistics.TestingAndersonDarlingTest

Namespace:  Accord.Statistics.Testing
Assembly:  Accord.Statistics (in Accord.Statistics.dll) Version: 3.8.0
Syntax
[SerializableAttribute]
public class AndersonDarlingTest : HypothesisTest<AndersonDarlingDistribution>, 
	IHypothesisTest<AndersonDarlingDistribution>, IHypothesisTest
Request Example View Source

The AndersonDarlingTest type exposes the following members.

Constructors
  NameDescription
Public methodAndersonDarlingTest
Creates a new Anderson-Darling test.
Top
Properties
  NameDescription
Public propertyCriticalValue
Gets the critical value for the current significance level.
(Inherited from HypothesisTestTDistribution.)
Public propertyPValue
Gets the P-value associated with this test.
(Inherited from HypothesisTestTDistribution.)
Public propertySignificant
Gets whether the null hypothesis should be rejected.
(Inherited from HypothesisTestTDistribution.)
Public propertySize
Gets the significance level for the test. Default value is 0.05 (5%).
(Inherited from HypothesisTestTDistribution.)
Public propertyStatistic
Gets the test statistic.
(Inherited from HypothesisTestTDistribution.)
Public propertyStatisticDistribution
Gets the distribution associated with the test statistic.
(Inherited from HypothesisTestTDistribution.)
Public propertyTail
Gets the test type.
(Inherited from HypothesisTestTDistribution.)
Public propertyTheoreticalDistribution
Gets the theoretical, hypothesized distribution for the samples, which should have been stated before any measurements.
Top
Methods
  NameDescription
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodStatic memberGetStatistic
Gets the Anderson-Darling statistic for the samples and target distribution.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodOnSizeChanged
Called whenever the test significance level changes.
(Inherited from HypothesisTestTDistribution.)
Public methodPValueToStatistic
Not supported.
(Overrides HypothesisTestTDistributionPValueToStatistic(Double).)
Public methodStatisticToPValue
Converts a given test statistic to a p-value.
(Overrides HypothesisTestTDistributionStatisticToPValue(Double).)
Public methodToString
Converts the numeric P-Value of this test to its equivalent string representation.
(Inherited from HypothesisTestTDistribution.)
Public methodToString(String, IFormatProvider)
Converts the numeric P-Value of this test to its equivalent string representation.
(Inherited from HypothesisTestTDistribution.)
Top
Extension Methods
  NameDescription
Public Extension MethodHasMethod
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)
Public Extension MethodIsEqual
Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.)
Public Extension MethodTo(Type)Overloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Public Extension MethodToTOverloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Top
Examples
// Test against a standard Uniform distribution
// References: http://www.math.nsysu.edu.tw/~lomn/homepage/class/92/kstest/kolmogorov.pdf

// Suppose we got a new sample, and we would like to test whether this
// sample seems to have originated from a uniform continuous distribution.
// 
double[] sample = 
{ 
    0.621, 0.503, 0.203, 0.477, 0.710, 0.581, 0.329, 0.480, 0.554, 0.382
};

// First, we create the distribution we would like to test against:
// 
var distribution = UniformContinuousDistribution.Standard;

// Now we can define our hypothesis. The null hypothesis is that the sample
// comes from a standard uniform distribution, while the alternate is that
// the sample is not from a standard uniform distribution.
// 
var adtest = new AndersonDarlingTest(sample, distribution);

double statistic = adtest.Statistic; //  1.3891622091168489561
double pvalue = adtest.PValue; // 0.2052

bool significant = adtest.Significant; // false

// Since the null hypothesis could not be rejected, then the sample
// can perhaps be from a uniform distribution. However, please note
// that this doesn't means that the sample *is* from the uniform, it
// only means that we could not rule out the possibility.
// Test against a Normal distribution

// This time, let's see if the same sample from the previous example
// could have originated from a standard Normal (Gaussian) distribution.
// 
double[] sample =
{ 
    0.621, 0.503, 0.203, 0.477, 0.710, 0.581, 0.329, 0.480, 0.554, 0.382
};

// Let's estimate a new Normal distribution using the sample
NormalDistribution distribution = NormalDistribution.Estimate(sample);

// Now, we can create a new Anderson-Darling's test:
var ad = new AndersonDarlingTest(sample, distribution);

// We can then compute the test statistic, 
// the test p-value and its significance:
double statistic = ad.Statistic; // 0.1796
double pvalue = ad.PValue; // 0.8884
bool significant = ad.Significant; // false
See Also