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.