Statistics for Data Science
Descriptive Statistics
Summarizing Data
Imagine you're handed a list of 1,000 test scores. Just looking at the raw numbers won't tell you much. Are the scores good? Are they all clustered together, or are they spread out? Answering these questions is the job of descriptive statistics. It’s a way to summarize and make sense of a large set of data using a few key numbers and pictures.
Descriptive statistics helps us turn a confusing pile of data into a clear story.
We'll focus on two main questions:
- What is the 'typical' value in our data? (Measures of Central Tendency)
- How spread out are the values? (Measures of Variability)
Finding the Center
Measures of central tendency give us a single value that represents the center or typical value of a dataset. The three most common are the mean, median, and mode.
Mean
noun
The sum of all values divided by the number of values. It's what most people call the 'average'.
The mean is straightforward, but it has a weakness: it can be skewed by outliers, which are unusually high or low values. For example, if the test scores are 85, 90, 88, 92, and a 20, the mean drops to 75. Does that score really represent the typical student's performance?
Median
noun
The middle value in a dataset that has been arranged in order from smallest to largest.
If you have an even number of values, the median is the mean of the two middle numbers. The median is resistant to outliers, making it a more reliable measure of center for skewed data.
Mode
noun
The value that appears most frequently in a dataset.
A dataset can have one mode, more than one mode (multimodal), or no mode at all if every value appears only once. The mode is especially useful for categorical data, like colors or names, where calculating a mean or median doesn't make sense.
Measuring the Spread
Knowing the center isn't enough. Imagine two classes have an average test score of 80. In one class, everyone scored between 78 and 82. In the other, scores ranged from 50 to 100. The average is the same, but the distributions are vastly different. Measures of variability, or spread, tell us how tightly clustered or spread out our data points are.
Range
noun
The difference between the highest and lowest values in a dataset.
The range is easy to calculate but, like the mean, is sensitive to outliers. It only considers the two most extreme values and ignores everything in between.
For a more robust measure, we use variance and standard deviation. They work together to describe the average distance of each data point from the mean.
A low standard deviation means the data is tightly packed around the mean. A high standard deviation means the data is spread out.
Variance () is the average of the squared differences from the Mean. We square the differences to make them all positive and to give more weight to larger differences.
The units of variance are squared (e.g., 'dollars squared'), which isn't very intuitive. To fix this, we take the square root of the variance to get the standard deviation ().
Standard Deviation
noun
A measure of how dispersed the data is in relation to the mean. It is the square root of the variance.
Visualizing Data
Numbers are great, but pictures are often better for understanding data at a glance. Histograms and box plots are two powerful tools for visualizing data distributions.
A histogram groups numbers into ranges (called bins) and shows how many data points fall into each bin. It's great for seeing the shape of your data. Is it symmetric, like a bell curve? Is it skewed to one side? Are there multiple peaks?
A box plot (or box-and-whisker plot) displays the five-number summary of a set of data: the minimum, first quartile (Q1), median, third quartile (Q3), and maximum. The 'box' shows the middle 50% of the data, also known as the interquartile range (IQR). Box plots are excellent for comparing the spread of several datasets at once.
A real estate website lists the following prices for houses in a neighborhood: 275,000, 325,000, and $1,500,000. Which measure of central tendency would give a misleadingly high impression of a 'typical' house price in this area?
What does a small standard deviation indicate about a dataset?
These descriptive tools are the first step in nearly any data analysis. By calculating these summary statistics and creating simple visualizations, you can begin to understand the key features of your data before diving into more complex modeling.