import numpy as np xx = [2,3,4,5,6] yy = [4,4,6,6,10] print("Data of x is :", xx) print("Data of y is :", yy) x = np.array(xx) y = np.array(yy) n = len(x) sum_x = np.sum(x) sum_y = np.sum(y) m_x = np.mean(x) m_y = np.mean(y) sum_xy = np.sum(np.multiply(x, y)) sum_xsq = np.sum(x**2) sum_ysq = np.sum(y**2) print("Number of Sample is :", n) print("Sum of x is :", sum_x) print("Sum of y is :", sum_y) print("Mean of x is :", m_x) print("Mean of y is :", m_y) print("Sum of x*y is :", sum_xy) print("Sum of x-square is :", sum_xsq) print("Sum of y-square is :", sum_ysq) var_x = (sum_xsq-m_x*sum_x)/(n-1) var_y = (sum_ysq-m_y*sum_y)/(n-1) std_x = np.sqrt(var_x) std_y = np.sqrt(var_y) sum_xy = np.sum(np.multiply(x, y)) cov_xy = (sum_xy-m_x*sum_y)/(n-1) corr_xy = cov_xy/(std_x*std_y) print("Variance of x :", var_x) print("Variance of y :", var_y) print("Standard deviation of x :", round(std_x, 6)) print("Standard deviation of y :", round(std_y, 6)) print("Covariance of x and y :", cov_xy) print("Correlation of x and y :", round(corr_xy, 6))