You are viewing a single comment's thread. Return to all comments →
from scipy.stats import pearsonr
physics_scores = [15, 12, 8, 8, 7, 7, 7, 6, 5, 3] history_scores = [10, 25, 17, 11, 13, 17, 20, 13, 9, 15]
r, _ = pearsonr(physics_scores, history_scores)
print(f"{r:.3f}")
Seems like cookies are disabled on this browser, please enable them to open this website
Correlation and Regression Lines - A Quick Recap #1
You are viewing a single comment's thread. Return to all comments →
from scipy.stats import pearsonr
Given data
physics_scores = [15, 12, 8, 8, 7, 7, 7, 6, 5, 3] history_scores = [10, 25, 17, 11, 13, 17, 20, 13, 9, 15]
Calculate Pearson's correlation coefficient
r, _ = pearsonr(physics_scores, history_scores)
Print the result formatted to three decimal places
print(f"{r:.3f}")