HypothesisTest_PartialSpearman(firstSample, secondSample, selection, level=0.95)

Test whether two discrete samples are not monotonous.

Available usages:

HypothesisTest_PartialSpearman(firstSample, secondSample, selection)

HypothesisTest_PartialSpearman(firstSample, secondSample, selection, 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.

selection : sequence of integers, maximum integer value < n

List of indices selecting which subsets of the first sample will successively be tested with the second sample through the Spearman test.

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 Partial Spearman Test is used to check hypothesis of non monotonous relation between two samples: firstSample of dimension n and secondSample of dimension 1. The parameter selection enables to select specific subsets of the firstSample to be tested.


>>> import openturns as ot
>>> ot.RandomGenerator.SetSeed(0)
>>> distribution = ot.Normal()
>>> sample = distribution.getSample(30)
>>> func = ot.SymbolicFunction(['x'], ['x', 'x^2', 'x^3', 'sin(5*x)'])
>>> testedSample = func(sample)
>>> test_result = ot.HypothesisTest.PartialSpearman(testedSample, sample, [0,3])
>>> print(test_result)
[class=TestResult name=Unnamed type=Spearman binaryQualityMeasure=false p-value threshold=0.05 p-value=0 description=[],class=TestResult name=Unnamed type=Spearman binaryQualityMeasure=true p-value threshold=0.05 p-value=0.57214 description=[]]