HypothesisTest_Spearman(firstSample, secondSample, level=0.95)

Test whether two discrete samples are not monotonous.

Available usages:

HypothesisTest.Spearman(firstSample, secondSample)

HypothesisTest.Spearman(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 Spearman Test is used to check whether two scalar samples have a monotonous relation.


>>> import openturns as ot
>>> ot.RandomGenerator.SetSeed(0)
>>> distribution = ot.Normal()
>>> firstSample = distribution.getSample(30)
>>> func = ot.NumericalMathFunction('x', 'x^2')
>>> secondSample = func(firstSample)
>>> test_result = ot.HypothesisTest.Spearman(firstSample, secondSample)
>>> print(test_result)
class=TestResult name=Unnamed type=TwoSampleSpearman binaryQualityMeasure=true p-value threshold=0.05 p-value=0.44348 description=[]