Definition: Covariance measures the extent to which two variables change in tandem. It indicates the direction of the linear relationship between variables, whether positive or negative.
Calculation: The formula for covariance (Cov) between two variables X and Y in a dataset with n observations is:
Cov(X,Y) = 1/n Σi=1n (Xi - X̄)(Yi - Ȳ)
Where:
Definition: Correlation measures the strength and direction of the linear relationship between two variables. Unlike covariance, correlation standardizes the measure to a range between -1 and 1, making it easier to interpret.
Calculation: The formula for correlation (r) between variables X and Y is:
r = Cov(X,Y) / (sX * sY)