FunctionRacerProblemsRace

Correlation

BeginnerNumPyPython

Return the correlation coefficient between the arrays x and y (the same length), as a float between -1 and 1. Hint: np.corrcoef(x, y) returns a 2 by 2 table; the number you want is off the diagonal.

Example 1

x [1,2,3]
y [2,4,6]
returns 1.0

y is exactly twice x, so they move together perfectly: 1.0.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More NumPy problems