All problems

A Seaborn Scatterplot From a DataFrame

easyPythonSeabornScatterplot

Fernbrook Analytics is asked, over and over, whether two things a client measures move together. The standard answer is a panel of points, one per record, with a single number printed underneath so nobody has to eyeball a slope. That number is the correlation: it runs from -1 to 1, where 1 means the two measurements rise together in a perfectly straight line, -1 means one rises exactly as the other falls, and 0 means no straight-line relationship at all.

Task: Print the correlation between the two measurements.

Input

The first line holds one integer n, the number of records. Each of the next n lines holds that record's two measurements, separated by a single space.

Output

One line holding the ordinary straight-line correlation — the Pearson kind, which works on the values themselves rather than on their rankings — rounded to exactly two decimal places. Keep the sign: a negative relationship prints with a minus.

Example:

Input:
4
1 10
2 20
3 30
4 40

Output:
1.00

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

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…