HypothesisTest_FullPearson(firstSample, secondSample, level=0.95)

Test whether two discrete samples are independent.

Available usages:

HypothesisTest.FullPearson(firstSample, secondSample)

HypothesisTest.FullPearson(firstSample, secondSample, level)


fisrtSample : 2-d sequence of float

First tested sample, of dimension n \geq 1.

secondSample : 2-d sequence of float

Second tested sample, of dimension 1.

level : positive float < 1

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


testResult : TestResult

Structure containing the result of the test.


The Full Pearson Test is the independence Pearson test between 2 samples : firstSample of dimension n and secondSample of dimension 1. If firstSample[i] is the numerical sample extracted from firstSample (i^{th} coordinate of each point of the numerical sample), FullPearson performs the independence Pearson test simultaneously on firstSample[i] and secondSample. For all i, it is supposed that the couple (firstSample[i] and secondSample) is issued from a gaussian vector.


>>> import openturns as ot
>>> ot.RandomGenerator.SetSeed(0)
>>> distCol = [ot.Normal()] * 3
>>> S = ot.CorrelationMatrix(3)
>>> S[0, 2] = 0.9
>>> copula = ot.NormalCopula(S)
>>> distribution = ot.ComposedDistribution(distCol, copula)
>>> sample = distribution.getSample(30)
>>> firstSample = sample[:, :2]
>>> secondSample = sample[:, 2]
>>> test_result = ot.HypothesisTest.FullPearson(firstSample, secondSample)
>>> print(test_result)
[class=TestResult name=Unnamed type=Pearson binaryQualityMeasure=false p-value threshold=0.05 p-value=7.23...e-14 description=[],class=TestResult name=Unnamed type=Pearson binaryQualityMeasure=true p-value threshold=0.05 p-value=0.895124 description=[]]