By the end of this lesson, you will be able to summarize a dataset using key descriptive statistics and interpret what these numbers reveal about central tendency and spread.
What it is
Descriptive statistics are numerical measures that summarize the main features of a collection of data. Unlike inferential statistics, which make predictions or generalizations about a larger population, descriptive stats simply describe what is already present in your sample. The mental model is "compression": you take thousands of raw data points and compress them into a few meaningful numbers. Key terms include Mean (average), Median (middle value), Mode (most frequent value), Variance (average squared deviation from the mean), and Standard Deviation (square root of variance, representing typical distance from the mean).Why it matters
- Quick Insight: Allows stakeholders to understand large datasets without reading every row.
- Data Quality Check: Extreme values in mean vs. median can reveal outliers or data entry errors.
- Baseline Comparison: Provides a reference point for tracking changes over time (e.g., monthly sales averages).
- Feature Engineering: Statistical summaries often become input features for machine learning models.
Syntax or steps
To perform basic descriptive analysis manually or conceptually: 1. Clean Data: Remove nulls or handle missing values appropriately. 2. Calculate Central Tendency: Compute Mean, Median, and Mode. 3. Calculate Dispersion: Compute Range (Max - Min), Variance, and Standard Deviation. 4. Interpret: Compare Mean and Median to check for skewness; look at Standard Deviation to assess consistency.Example
While this topic focuses on concepts, here is a minimal Python example using the standard library to calculate basic stats without external dependencies like Pandas.import statistics
# Sample data: Daily website visitors
data = [105, 98, 112, 105, 120, 95, 105]
mean_val = statistics.mean(data)
median_val = statistics.median(data)
stdev_val = statistics.stdev(data) # Sample standard deviation
print(f"Mean: {mean_val}")
print(f"Median: {median_val}")
print(f"Std Dev: {stdev_val:.2f}")
Explanation:
The code defines a list of integers. statistics.mean() sums all values and divides by the count. statistics.median() sorts the data and picks the middle number. statistics.stdev() calculates how much the values typically vary from the mean. In this output, if the Mean is significantly higher than the Median, the data is skewed right (likely due to high outliers).
Common mistakes
- Ignoring Outliers: Using the Mean when the Median would be more representative because of extreme values (e.g., income data).
- Misinterpreting Standard Deviation: Assuming a low SD means "good" quality; it only means "consistent," which could be consistently bad.
- Confusing Population vs. Sample: Using the formula for population variance ($\sigma^2$) when analyzing a sample ($s^2$), leading to underestimation of variability.
- Blindly Reporting Numbers: Presenting stats without context or units, making them meaningless to non-technical audiences.
When to use it
Use descriptive statistics for initial exploration and reporting. Use inferential statistics when you need to test hypotheses or predict future trends.| Scenario | Best Approach | Reason |
|---|---|---|
| Summarizing last month's sales | Descriptive Stats | You have the full data for that period; no prediction needed. |
| Predicting next quarter's growth | Inferential Stats | You must generalize from past samples to future unknowns. |
| Detecting fraud anomalies | Descriptive + Visual | Identify values far outside the normal distribution range. |
Practice
Guided Exercise: Given the dataset[2, 4, 4, 4, 5, 5, 7, 9], calculate the Mean and Median.
Hint: Sum all numbers and divide by 8 for Mean. Sort and find the average of the two middle numbers for Median.
Challenge: Why might the Mean and Median differ in real-world salary data? Write one sentence explaining the role of executives' salaries in this difference.