Marginal Distributions Plus Regression With jointplot
Calder Engineering's summary figure puts the paired readings in the middle, with a fitted line through them, and each measurement's own distribution along the top and the right-hand side -- so a lopsided or double-peaked measurement cannot hide inside the cloud. Underneath the figure, the sheet states in writing how tightly the two move together.
Task: Print the correlation between x and y.
Input
The first line holds one integer n, the number of readings, where 2 <= n <= 1000. Then come n lines, each holding a reading's x and y separated by a single space. Neither column holds the same value throughout.
Output
One line holding the Pearson correlation of x and y -- the ordinary straight-line one, running from -1 for a perfect fall through 0 for no straight-line link to +1 for a perfect rise -- rounded to 2 decimal places.
Example:
Input:
4
1 2
2 4
3 5
4 9
Output:
0.96
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