ChiSquared

ChiSquared(firstSample, secondSample, level=0.05)

Test whether two discrete samples are independent.

Parameters:
firstSample2-d sequence of float

First tested sample, of dimension 1.

secondSample2-d sequence of float

Second tested sample, of dimension 1.

levelpositive float < 1, optional

Threshold p-value of the test (= first kind risk), it must be < 1, equal to 0.05 by default.

Returns:
testResultTestResult

Structure containing the result of the test.

See also

HypothesisTest.Pearson, HypothesisTest.Spearman

Examples

>>> import openturns as ot
>>> ot.RandomGenerator.SetSeed(0)
>>> distCol = [ot.Poisson(3), ot.Binomial(10, 0.3)]
>>> distribution = ot.ComposedDistribution(distCol)
>>> sample = distribution.getSample(30)
>>> test_result = ot.HypothesisTest.ChiSquared(sample[:,0], sample[:,1])
>>> print(test_result)
class=TestResult name=Unnamed type=ChiSquared binaryQualityMeasure=true p-value threshold=0.05 p-value=0.855945 statistic=4.74502 description=[]
>>> independent_samples = test_result.getBinaryQualityMeasure()