diff --git a/medium/Calculate_Correlation_Matrix/Calculate_Correlation_Matrix.py b/medium/Calculate_Correlation_Matrix/Calculate_Correlation_Matrix.py index 18bbe01..65179e0 100644 --- a/medium/Calculate_Correlation_Matrix/Calculate_Correlation_Matrix.py +++ b/medium/Calculate_Correlation_Matrix/Calculate_Correlation_Matrix.py @@ -1,9 +1,14 @@ import numpy as np -def calculate_correlation_matrix(X : np.ndarray, Y=None): +def calculate_correlation_matrix(X, Y=None): # Your code here - pass + if Y: + pass + cov = np.cov(X) + std = np.std(X) + corr = cov / std * std + return corr X = np.array([[1, 2], [3, 4], [5, 6]])