All problems
Correlation from Covariance
Problem
The correlation coefficient is Cov(X, Y) / (sigma_X sigma_Y).
Given the covariance and the two standard deviations (positive), return the correlation.
Hint
It normalizes away the scales.
Test cases
case 1
in: [2,1,2]
expected: 1
case 2
in: [0,3,1]
expected: 0
case 3
in: [-1,1,1]
expected: -1
Starter codePython
def correlation_from_covariance(cov, sigma_x, sigma_y):
# Your code here
pass3 test cases · run your code against them in the editor