Estimate Spearman correlation coefficentΒΆ

In this example we are going to estimate the Spearman correlation coefficient from two unidimensional samples.

In [20]:
from __future__ import print_function
import openturns as ot
In [21]:
# Create data
dimension = 2
R = ot.CorrelationMatrix(dimension)
R[0, 1] = 0.8
size = 100
sample = ot.Normal([3.] * dimension, [2.] * dimension, R).getSample(size)
sample1 = sample.getMarginal(0)
sample2 = sample.getMarginal(1)
In [22]:
# Estimate the Spearman correlation
coef = ot.CorrelationAnalysis.SpearmanCorrelation(sample1, sample2)
print(coef)
0.8000480048004801
In [ ]: