Skip to content

Instantly share code, notes, and snippets.

@sergeymong
Created January 5, 2021 13:37
Show Gist options
  • Save sergeymong/d43944ca0289f8a6e63a34be1891f87d to your computer and use it in GitHub Desktop.
Save sergeymong/d43944ca0289f8a6e63a34be1891f87d to your computer and use it in GitHub Desktop.
[Pearson correlation coefficient] Between two variables #Python #Numpy #EDA #Statistics
def pearson_r(x, y):
"""Compute Pearson correlation coefficient between two arrays."""
# Compute correlation matrix: corr_mat
corr_mat = np.corrcoef(x, y)
# Return entry [0,1]
return corr_mat[0,1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment