Spearman Rank Correlation

easy
Unit 1 · Statistics I0/3 to milestone

Pearson correlation only measures linear relationships and is thrown off by outliers. Spearman correlation is Pearson correlation applied to the ranks, so it captures any monotonic relationship.

Implement rank_average(values) (1-based ranks, with ties getting the average rank) and spearman(x, y), which ranks both and returns the Pearson correlation of the ranks. Return 0.0 if either side is constant.

#statistics#correlation2 visible + 2 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Spearman Rank Correlation · TechGradify