ChiSquareTest Class 
Namespace: Accord.Statistics.Testing
The ChiSquareTest type exposes the following members.
Name  Description  

ChiSquareTest 
Constructs a ChiSquare Test.
 
ChiSquareTest(Double, Int32) 
Constructs a ChiSquare Test.
 
ChiSquareTest(Double, IUnivariateDistributionDouble) 
Constructs a ChiSquare Test.
 
ChiSquareTest(ConfusionMatrix, Boolean) 
Constructs a ChiSquare Test.
 
ChiSquareTest(GeneralConfusionMatrix, Boolean) 
Constructs a ChiSquare Test.
 
ChiSquareTest(Double, Double, Int32) 
Constructs a ChiSquare Test.

Name  Description  

CriticalValue 
Gets the critical value for the current significance level.
(Inherited from HypothesisTestTDistribution.)  
DegreesOfFreedom 
Gets the degrees of freedom for the ChiSquare distribution.
 
PValue 
Gets the Pvalue associated with this test.
(Inherited from HypothesisTestTDistribution.)  
Significant 
Gets whether the null hypothesis should be rejected.
(Inherited from HypothesisTestTDistribution.)  
Size 
Gets the significance level for the
test. Default value is 0.05 (5%).
(Inherited from HypothesisTestTDistribution.)  
Statistic 
Gets the test statistic.
(Inherited from HypothesisTestTDistribution.)  
StatisticDistribution 
Gets the distribution associated
with the test statistic.
(Inherited from HypothesisTestTDistribution.)  
Tail 
Gets the test type.
(Inherited from HypothesisTestTDistribution.) 
Name  Description  

Compute 
Computes the ChiSquare Test.
 
Equals  Determines whether the specified object is equal to the current object. (Inherited from Object.)  
Finalize  Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)  
GetHashCode  Serves as the default hash function. (Inherited from Object.)  
GetType  Gets the Type of the current instance. (Inherited from Object.)  
MemberwiseClone  Creates a shallow copy of the current Object. (Inherited from Object.)  
OnSizeChanged 
Called whenever the test significance level changes.
(Inherited from HypothesisTestTDistribution.)  
PValueToStatistic 
Converts a given pvalue to a test statistic.
(Overrides HypothesisTestTDistributionPValueToStatistic(Double).)  
StatisticToPValue 
Converts a given test statistic to a pvalue.
(Overrides HypothesisTestTDistributionStatisticToPValue(Double).)  
ToString 
Converts the numeric PValue of this test to its equivalent string representation.
(Inherited from HypothesisTestTDistribution.)  
ToString(String, IFormatProvider) 
Converts the numeric PValue of this test to its equivalent string representation.
(Inherited from HypothesisTestTDistribution.) 
Name  Description  

HasMethod 
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)  
IsEqual 
Compares two objects for equality, performing an elementwise
comparison if the elements are vectors or matrices.
(Defined by Matrix.)  
To(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.)  
ToT  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.) 
A chisquare test (also chisquared or χ² test) is any statistical hypothesis test in which the sampling distribution of the test statistic is a chisquare distribution when the null hypothesis is true, or any in which this is asymptotically true, meaning that the sampling distribution (if the null hypothesis is true) can be made to approximate a chisquare distribution as closely as desired by making the sample size large enough.
The chisquare test is used whenever one would like to test whether the actual data differs from a random distribution.
References:
The following example has been based on the example section of the Pearson's chisquared test article on Wikipedia.
// Suppose we would like to test the hypothesis that a random sample of // 100 people has been drawn from a population in which men and women are // equal in frequency. // Under this hypothesis, the observed number of men and women would be // compared to the theoretical frequencies of 50 men and 50 women. So, // after drawing our sample, we found out that there were 44 men and 56 // women in the sample: // man woman double[] observed = { 44, 56 }; double[] expected = { 50, 50 }; // If the null hypothesis is true (i.e., men and women are chosen with // equal probability), the test statistic will be drawn from a chisquared // distribution with one degree of freedom. If the male frequency is known, // then the female frequency is determined. // int degreesOfFreedom = 1; // So now we have: // var chi = new ChiSquareTest(expected, observed, degreesOfFreedom); // The chisquared distribution for 1 degree of freedom shows that the // probability of observing this difference (or a more extreme difference // than this) if men and women are equally numerous in the population is // approximately 0.23. double pvalue = chi.PValue; // 0.23 // This probability is higher than conventional criteria for statistical // significance (0.001 or 0.05), so normally we would not reject the null // hypothesis that the number of men in the population is the same as the // number of women. bool significant = chi.Significant; // false