Click or drag to resize
Accord.NET (logo)

LillieforsTest Class

One sample Lilliefors' corrected Kolmogorov-Smirnov (KS) test.
Inheritance Hierarchy
SystemObject
  Accord.Statistics.TestingHypothesisTestEmpiricalDistribution
    Accord.Statistics.TestingLillieforsTest

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

The LillieforsTest type exposes the following members.

Constructors
  NameDescription
Public methodLillieforsTest
Creates a new One-Sample Lilliefors' Kolmogorov-Smirnov test.
Top
Properties
  NameDescription
Public propertyCriticalValue
Gets the critical value for the current significance level.
(Inherited from HypothesisTestTDistribution.)
Public propertyEmpiricalDistribution
Gets the empirical distribution measured from the sample.
Public propertyHypothesis
Gets the alternative hypothesis under test. If the test is Significant, the null hypothesis can be rejected in favor of this alternative hypothesis.
Public propertyNumberOfSamples
Gets the number of observations in the sample being tested.
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 hypothesized distribution for the samples.
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 methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodStatic memberGoodnessOfFitTDistribution
Performs a Goodness-of-Fit method by automatically creating and fitting the chosen distribution to the samples and computing a LillieforsTest against this fitted distribution.
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
Converts a given p-value to a test statistic.
(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
Remarks

In statistics, the Lilliefors test, named after Hubert Lilliefors, professor of statistics at George Washington University, is a test based on the Kolmogorov–Smirnov test. It is used to test the null hypothesis that data come from a normally distributed population, when the null hypothesis does not specify which normal distribution; i.e., it does not specify the expected value and variance of the distribution.

Contrary to the Kolmogorov-Smirnov test, this test can be used to assess the likelihood that a given sample could have been generated from a distribution that has been fitted from the data.

References:

Examples

In this first example, suppose we got a new sample, and we would like to test whether this sample has been originated from a uniform continuous distribution. Unlike KolmogorovSmirnovTest, we can actually use this test whether the data fits a distribution that has been estimated from the data.

// Test against a Uniform distribution fitted from the data

// Make this example reproducible
Accord.Math.Random.Generator.Seed = 1;

// 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.021, 0.003, 0.203, 0.177, 0.910, 0.881, 0.929, 0.180, 0.854, 0.982
};

// First, we create the distribution we would like to test against:
// 
var distribution = UniformContinuousDistribution.Estimate(sample);

// 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 lillie = new LillieforsTest(sample, distribution, iterations: 10 * 1000 * 1000);

double statistic = lillie.Statistic; // 0.36925
double pvalue = lillie.PValue; // 0.09057

bool significant = lillie.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.

We can also check whether a Normal distribution fitted on the data is a good candidate model for the samples:

// Test against a Normal distribution

// Make this example reproducible
Accord.Math.Random.Generator.Seed = 1;

// This time, let's see if the same sample from the previous example
// could have originated from a fitted Normal (Gaussian) distribution.
// 
double[] sample = 
{
    0.021, 0.003, 0.203, 0.177, 0.910, 0.881, 0.929, 0.180, 0.854, 0.982
};

// Before we could not rule out the possibility that the sample came from
// a uniform distribution, which means the sample was not very far from
// uniform. This would be an indicative that it would be far from what
// would be expected from a Normal distribution:

NormalDistribution distribution = NormalDistribution.Estimate(sample);

// Create the test
var lillie = new LillieforsTest(sample, distribution);

double statistic = lillie.Statistic; // 0.2882
double pvalue = lillie.PValue; // 0.0207

bool significant = lillie.Significant; // true

// Since the test says that the null hypothesis should be rejected, then
// this can be regarded as a strong indicative that the sample does not
// comes from a Normal distribution, just as we expected.
See Also