avatarArpita Ghosh

Summary

The article provides a comprehensive guide on calculating variability measures such as variance, standard deviation, and coefficient of variation in statistics, with practical examples and Python coding implementation.

Abstract

The blog post delves into the concept of variability measures in statistics, emphasizing the importance of understanding variance, standard deviation, and coefficient of variation. It explains the rationale behind different formulas for population and sample data, with visual aids and examples to illustrate these concepts. Additionally, the author discusses the significance of standard deviation as a more interpretable measure compared to variance, due to its square root transformation. The post also covers the calculation of the coefficient of variation, which allows for the comparison of standard deviations across different data sets. Furthermore, the article extends to the relationship between two variables through covariance and correlation, explaining how these measures can indicate the degree and direction of the relationship between variables. The author provides Python code snippets to demonstrate how to compute these statistics, enhancing the learning experience with embedded YouTube tutorials. The article concludes with an invitation for readers to engage with the content by asking questions in the comments section.

Opinions

  • The author believes that understanding variability measures is crucial for statistical analysis.
  • There is an emphasis on the practical application of these measures, as demonstrated by the Python coding examples provided.
  • The author suggests that the choice between population and sample formulas is significant due to the inherent differences in data certainty.
  • The article implies that standard deviation is a more user-friendly measure than variance because it is easier to interpret.
  • The author posits that the coefficient of variation is particularly useful when comparing the variability of different data sets.
  • Covariance and correlation are presented as essential tools for understanding the relationship between two variables, with correlation being more interpretable due to its normalized nature.
  • The use of embedded YouTube videos indicates the author's preference for multimedia learning aids to complement textual explanations.

How to Calculate Variability measures (variance SD etc) in Statistics and Python

Image by Author

In this blog, I am going to talk about Variability measures with hands on in python. If you miss my previous blog about Central Tendency and Asymmetry measures with Python, please go to the below link. https://readmedium.com/how-to-calculate-central-tendency-and-asymmetry-measures-in-statistics-and-python-28b2bc10407d

Now it is time for measuring variability of data. Most commonly use measures are variance , standard deviation and coefficient of variance.

Variance, Standard Deviation & Coefficient of variation (CV):

These two measure the distribution of a set of data points around its mean value.

Reason for different formulas of population and sample data: When we are calculating for population data, we are 100% sure about measures. When we are considering sample data, there may be 5 sample data sets and for those 5 different measures. Due to this reason there are different formulas.

Population variance formula:

Sample variance formula:

Here we are obtaining the result based on the difference of data point value from the mean of data set. So data point is close to mean, that means lower result and when it is far, that means higher result. Reason for squaring the difference, is not considering negative values as we taking the distance between one point to another.

Variance Example:

Standard Deviation: As variance is a square number, so it is a large value. Due to this standard deviation is coming to picture using square root function.

Population standard deviation formula

Sample standard deviation formula

Coefficient of variation (CV): Coefficient of variation is (standard deviation /mean). When we are comparing standard deviation of two or more data sets, those are meaningless. But comparing coefficient of variation is meaning full.

Coefficient of variation Example:

Python Coding for Variance, Standard Deviation and Coefficient of variation:

We have covered all univariate measures, now it’s time to explore measures which are related between two variables.

Covariance & Correlation:

Covariance: Covariance is a measure of the joint variability of two variables.

A positive covariance means that the two variables move together.

A covariance of 0 means that the two variables are independent.

A negative covariance means that the two variables move in opposite directions.

Covariance can take on values from -∞ to +∞.

This is a problem as it is very hard to calculate such numbers.

Sample Covariance formula:

Population Covariance formula:

Covariance Example:

Correlation: Correlation is a measure of the joint variability of two variables. Unlike covariance, it takes on values between -1 and 1, thus it is easy for us to interpret the result.

A correlation of 1 is known as perfect positive correlation which means that one variable is perfectly explained by the other.

A correlation of 0 means that the variables are independent.

A correlation of -1, is known as perfect negative correlation which means that one variable is explaining the other one perfectly, but they move in opposite directions.

Sample correlation formula

Population correlation formula

Correlation Example:

Python Code for Covariance and Correlation:

Conclusion: In this blog, we learn how to do python coding for variability measures of statistics. If you have any questions, please post them in the comment section.

Statistics
Python
Data Science
Machine Learning
Women In Tech
Recommended from ReadMedium