1# For a measure the strength of association between two variables;
2import numpy as np
3from scipy.stats import spearmanr, pearsonr, kendalltau
4serie1 = np.array([-2, -1, 0, 1, 4])
5serie2 = np.array([-2.5, -.75, 1, 2, 6])
6
7# linear ==> Pearson
8pearsonr(serie1, serie2)
9pearsonrResult(correlation=0.9964803994464919, pvalue=0.0002505212149642603)
10
11# Non-linear ==> Spearman or kendall
12spearmanr(serie1, serie2)
13SpearmanrResult(correlation=0.9999999999999999, pvalue=1.4042654220543672e-24)
14kendalltau(serie1, serie2)
15KendalltauResult(correlation=0.9999999999999999, pvalue=0.016666666666666666)
16