A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/python/cpython/issues/95861 below:

Add Spearman correlation support to statistics.correlation() · Issue #95861 · python/cpython · GitHub

Spearman correlation would be easily supported by adding a ranked option to statistics.correlation(). It is appropriate for ordinal data or for continuous data that doesn't meet the linear proportionality assumption required for Pearson correlation.

>>> # Example from https://statistics.laerd.com/statistical-guides/spearmans-rank-order-correlation-statistical-guide.php
>>> eng = [56, 75, 45, 71, 61, 64, 58, 80, 76, 61]
>>> math = [66, 70, 40, 60, 65, 56, 59, 77, 67, 63]

>>> # Pearson correlation reports the strength of a linear relationship
>>> correlation(math, eng)      
0.8005386765540159

>>> # Spearman correlation reports strength of a monotonic relationship
>>> correlation(math, eng, ranked=True)    
0.6686960980480711

The code would be mostly unchanged. If ranked is true, then the data is replaced by rankings using a helper function


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4