All problems

Do Hours Studied and Scores Move Together?

hardPythonNumPynp.cov

A Fenwick College study asks whether students who put in more hours come out with better exam scores. Each student contributes two figures — hours studied and exam score — and the two rows line up student by student. The study reports the covariance between them: a positive figure means the two tend to be high together, a negative figure means one tends to be high when the other is low, and a figure near zero means they drift independently. These students are a sample drawn from a much larger cohort, so the sample convention is the one the study uses.

Task: Print the sample covariance between the hours row and the scores row.

Input

Three lines. The first holds a single integer n, the number of students. The second holds the n hours figures on one line, separated by single spaces. The third holds the n exam scores, in the same student order.

Output

One line holding the covariance with exactly two digits after the decimal point. A negative covariance carries a leading minus sign.

Example:

Input:
4
1 2 3 4
50 60 70 80

Output:
16.67

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…