Summarize and compare groups
Use descriptive statistics to describe distributions and group differences.
- Calculate and interpret a mean, median, and group summary without overstating the result.
Descriptive statistics summarize the data you have. The mean uses every value and can be pulled by extreme values; the median is the middle value after sorting and is often more robust to skew. Always include context such as units, sample size, and spread. A difference in group averages describes the observed groups, but does not automatically explain why they differ.
1values = sorted([4, 7, 8, 30])
2median = (values[1] + values[2]) / 2
3print("mean:", sum(values) / len(values))
4print("median:", median)mean: 12.25 median: 7.5
For an even number of observations, the median is the average of the two middle sorted values. A single center number hides variation, so examine the distribution and relevant subgroups too.
Key takeaways
Calculate and interpret a mean, median, and group summary without overstating the result.
Check how the data was collected before drawing conclusions.
Explain important assumptions and limitations.
Lesson quiz
3 questions · pass with 3 correct · up to 50 XP
Passing this quiz completes the lesson and keeps your streak going. Questions you miss come back in review sessions later.
Practice: write Python
Write Python in the editor and run it against sample inputs. Python runs locally in your browser using a WebAssembly runtime.
Calculate a median
Read a JSON array of an odd number of numeric values, sort it, and print its median.
- Unsorted values
- Negative values
Python runs in a sandboxed browser worker with a 60 second time limit. Its runtime loads from the Pyodide CDN; your code stays in this browser.
Questions about this lesson
Stuck? Ask. Figured something out? Share it. Explaining is one of the best ways to learn.
Loading posts…