Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add Spearman correlation support to statistics.correlation() #95861

Closed
Assignees
stevendaprano
Labels
3.12only security fixesstdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement
@rhettinger

Description

@rhettinger

Spearman correlation would be easily supported by adding aranked option tostatistics.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. Ifranked is true, then the data is replaced by rankings using a helper function

Metadata

Metadata

Assignees

Labels

3.12only security fixesstdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp