Correlation of Study Hours and Scores
Same Lantern Tutors pilot, same cohorts, same two paired lists of hours and marks.
The owner has the covariance and cannot do anything with it. 1.5 hour-marks means nothing to her on its own, it will mean something different next term when the app starts logging minutes instead of hours, and she cannot hold it up against the same figure from the reading programme, which is measured in pages. She wants the version with the units scaled out - one that always lands between -1 and 1, so a strong link looks strong no matter what anything was measured in, and so that two cohorts of different sizes can sit in the same table.
Task: Print the Pearson correlation coefficient between the hours and the marks - the straight-line one based on the values themselves, not the rank-based alternative - rounded to 2 decimals.
Input
Two lines. The first holds the hours, one per student, separated by single spaces. The second holds the marks in the same order. Both lines hold the same number of entries, there are at least two, and neither list is entirely made of one repeated value.
Output
One line holding the Pearson coefficient, rounded to 2 decimals and printed the way Python prints a float - 0.77, -0.7 when the two move in opposite directions, and 1.0 for a perfect straight line.
Example:
Input:
1 2 3 4 5
2 4 5 4 5
Output:
0.77
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in