Covariance@3PM 24th Sep
Covariance@3PM 24th Sep
Interpretation:
Positive Covariance: Indicates that the two variables tend to
increase together.
Negative Covariance: Indicates that as one variable increases, the
other decreases.
Zero Covariance: Indicates no linear relationship between the
variables.
Covariance is useful in determining the relationship between two
variables, but it does not give insight into the strength of the relationship.
To measure the strength, you would typically look at the correlation.
Example:
Let's calculate the covariance between two variables:
X = [2, 4, 6, 8, 10] and Y = [1, 3, 5, 7, 9].
PYTHON CODE:
import numpy as np
# Data for two variables X and Y
X = [2, 4, 6, 8, 10]
Y = [1, 3, 5, 7, 9]
Correlation:
Correlation is a statistical measure that describes the strength and
direction of a linear relationship between two variables. The most
commonly used correlation coefficient is Pearson's correlation coefficient,
which ranges from -1 to +1:
Step-by-Step Calculation:
Finally:
PYTHON CODE:
import numpy as np
# Data for two variables X and Y
X = [2, 4, 6, 8, 10]
Y = [1, 3, 5, 7, 9]
# Calculate the Pearson correlation coefficient
correlation = np.corrcoef(X, Y)[0, 1]
print("Correlation between X and Y:", correlation)
Coefficient of Variation (CV): The CV is the ratio of the standard
deviation to the mean expressed as a percentage. It is used to compare
the variability of datasets with different means and is commonly used in
fields such as biology, chemistry, and engineering.
OR
Example:
Consider the following incomes (in thousands of dollars):
45,50,55,60,65
Conclusion:
The Coefficient of Variation (CV) is approximately 12.86%, which indicates
that the income values vary by about 12.86% relative to the mean income
of $55,000.
PYTHON Example:
import numpy as np
# Dataset of incomes (in thousands of dollars)
incomes = [45, 50, 55, 60, 65]
mean_income, std_deviation, cv