Skip to content

Add Pearson correlation coefficient - #21

Open
DjYash007 wants to merge 2 commits into
bsoc-bitbyte:mainfrom
DjYash007:correlation
Open

Add Pearson correlation coefficient #21
DjYash007 wants to merge 2 commits into
bsoc-bitbyte:mainfrom
DjYash007:correlation

Conversation

@DjYash007

Copy link
Copy Markdown
Contributor

Overview

This PR does the following:
Implement Pearson correlation coefficient in primary/correlation.rs.

Pearson correlation coefficient is a statistical measure of the strength and direction of the linear relationship between to variables.

image

Features:

  • Reuses the existing covariance and std_deviation implementations
  • Returns None when:
    • input lengths differ
    • fewer than two values are provided
    • either input has zero standard deviation
  • Added tests for:
    • empty inputs
    • different input lengths
    • single element
    • zero standard deviation
    • smallest valid input
    • perfect positive correlation
    • perfect negative correlation
    • decimal values
    • multiple values
    • zero correlation

Essential Checklist

  • The PR title starts with "Fix #bugnum: ", followed by a short, clear summary of the changes. (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • "Allow edits from maintainers" is checked. (See here for instructions on how to enable it.)
  • The PR is made from a branch that's not called "main/master".

Proof that changes are correct

2026-08-01-051758

PR Pointers

  • If you need a review or an answer to a question, and don't have permissions to assign people, leave a comment like the following: "{{Question/comment}} @{{reviewer_username}} PTAL".
  • Never force push. If you do, your PR will be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant