Summarizing Center, Spread, and Distribution
After Finishing This Topic
You will be able to distinguish the mean and the median, which describe the center of data, from the standard deviation and the IQR, which describe its spread. Using Python, you will see how two datasets with the same center can have different distributions, and you will be able to interpret data without letting a single summary value stand in for the structure of the observations.
Starting Point: Does the Same Mean Imply the Same Data?
Suppose the outcome measured under two conditions has the same mean. Does that fact alone let us say the data from the two conditions are similar?
Not necessarily. The values under one condition may cluster around the mean, while under the other condition some values may lie far away. Conversely, even when the means differ, most of the observations may overlap. The center summarizes location, the spread describes how widely the values are scattered, and the distribution reveals shape that those two pieces of information alone cannot capture.
The purpose of this topic is not to conclude that one treatment condition is superior to another. Instead of approved external data, we use two groups that we synthesize ourselves in order to confirm that summary statistics are one perspective on the structure of data.
Checking the Unit of Analysis and the Data Shape
As we saw in the previous topic, you must first confirm what a single row means. In the example below, we assume that one row is a single outcome obtained from an independent unit of analysis. This requires the premise that technical replicates were not added as independent samples.
The data contract we will use is as follows.
| Column | Meaning | Data type | Unit |
|---|---|---|---|
condition | The condition being compared | String | A or B |
outcome | The measured value under analysis | Float | Arbitrary unit defined here |
In actual research, you would need to record more about units, measurement time points, missing values, and replicate structure. Here we have reduced the number of variables in order to show the computational structure of center and spread.
Two Perspectives for Summarizing the Center
Mean
The mean is the value obtained by adding up all the observations and dividing by the number of observations. Because the mean reflects the magnitude of every value in its calculation, it can be affected by values that lie far away. This property is not an error; it is how the mean summarizes data.
Median
This is the value located in the middle when the values are arranged in order of size. It provides positional information: half of the observations are less than or equal to it, and the other half are greater than or equal to it. When there is an even number of values, we use the rule that defines it from the two middle values.
The median is not always better than the mean. If the question calls for an average total or an expected level, the mean can be the important summary; if you want to see the middle position of the distribution, the median can be useful. The choice must be explained in terms of the relationship between the data and the question.
Two views for summarizing spread
Standard deviation
The standard deviation summarizes, in a single unit, how widely the observations are spread around the mean. Because it is calculated relative to the mean, it can be affected by large or small values. A small standard deviation means that the values in this dataset are more tightly clustered around the mean; it does not automatically guarantee the conclusion that the measurement is accurate or that the biological variation is small.
Interquartile range (IQR)
The IQR is the difference between the 75th percentile and the 25th percentile. Because it expresses the range occupied by the middle 50%, the influence of extreme values can be more limited than for the standard deviation. However, the IQR is also not a value that shows the entire distribution, and shapes such as tails and multiple peaks require separate visualization.
Checking synthetic data with Python
The code below does not replicate any particular dataset; it is an example for creating two conditions with similar centers but different spread and extremes. The random number generator of numpy and the DataFrame, groupby, and describe APIs of pandas must be verified against the versions in requirements-lock.txt.
import numpy as npimport pandas as pd
rng = np.random.default_rng(20260806)group_a = rng.normal(loc=10.0, scale=0.8, size=20)group_b = np.concatenate([ rng.normal(loc=10.0, scale=0.8, size=18), np.array([6.0, 14.0]),])
data = pd.DataFrame({ "condition": ["A"] * len(group_a) + ["B"] * len(group_b), "outcome": np.concatenate([group_a, group_b]),})
summary = data.groupby("condition")["outcome"].agg( mean="mean", median="median", sd="std", q1=lambda s: s.quantile(0.25), q3=lambda s: s.quantile(0.75),)summary["iqr"] = summary["q3"] - summary["q1"]print(summary.round(2))This code turns the input into a two-column DataFrame and calculates the center and spread for each condition. Because std uses the standard deviation calculation rule provided by pandas, you should check the API and default values of your execution environment before recording the results. summary is a result object in table form, and it alone does not express every characteristic of the distribution.
How to read the results
In the execution results, first check the relationship between the mean and the median for each condition. If the two values differ, you can examine the possibility of asymmetry in the distribution or the influence of some values. Next, compare the magnitudes of the SD and the IQR. The mere fact that a particular summary quantity is larger or smaller is not grounds for deciding to delete an outlier or to call it a measurement error.
Because this data placed two distant values in B, the spread summaries for B may appear different from those for A. What matters is knowing that this difference arose from the synthetic data generation rules. This output cannot be interpreted as showing that any actual biological condition is superior.
Reading the results together with the distribution
The mean and SD are one summary showing location and spread centered on the mean. The median and IQR are a different summary showing the location and spread of the middle region. Do not automate the rule for choosing between the two based only on the superficial shape of the data.
At minimum, record the following questions together.
- What analytical unit does one row represent?
- What are the units of the outcome and when was it measured?
- Are there missing values?
- How much do the mean and the median differ?
- How much do the SD and the IQR differ?
- Are the observations concentrated in a single group, or are there multiple peaks or tails?
The last question is hard to answer with a table alone. You should also use visualizations that reveal where the observations lie, such as histograms, dot plots, and box plots. The visualization should state the axes and units, and the meaning of the observational unit.
Returning to the research question for interpretation
What this topic can say is roughly this: "in our own synthetic data, the center and spread per condition are summarized by certain computational rules, and the summary statistics reflect different pieces of information." To speak about treatment effects, biological importance, or causation in real research, you must additionally examine the study design, the measurement process, uncertainty, and the purpose of the comparison.
Also, a small standard deviation or IQR does not by itself mean that a biological system is stable. You should also check whether the measurement range was narrow, whether a particular unit was chosen, or whether a replicate structure was summarized incorrectly. Statistical summaries are tools for sharpening a question, not devices that decide the meaning of the data on your behalf.
Common failures and how to check for them
Using mean 卤 SD as the default notation for all data
There are situations where the mean and SD are useful, but not every distribution is adequately described by that combination. Check the median and IQR together with the distribution of the raw data.
Deleting outliers automatically
A distant value may be an input error, a measurement problem, or genuine variation. Do not remove a value merely because it stands out; check the measurement records and the purpose of the study, then record the reason for how it was handled.
Accumulating technical replicates as the number of observations
Apply first the analytical unit and replicate structure defined in the previous topic. Even if the computation of the summary statistics is correct, the interpretation changes if the independent unit is defined incorrectly.
Mistaking a summary value for the distribution itself
The mean, median, SD, and IQR compress part of the information in the data. Different distributions can have similar summary values, so look at the raw data and visualizations together when needed.
Key points
- The mean and the median summarize the center in different ways.
- The standard deviation and the IQR express spread from different perspectives.
- The choice of summary statistic must be explained together with the question, the units, and the distribution.
- Execution results on synthetic data can be used to verify computation, but they are not real biological conclusions.
- A single summary value cannot substitute for the whole distribution and the independence structure.
On to the next topic
In the next topic, we visualize distributions and check for outliers. After computing center and spread, we move on to the stage of confirming the shape and quality of the data with graphs.
References
- NumPy Reference: https://numpy.org/doc/stable/reference/
- pandas User Guide: https://pandas.pydata.org/docs/user_guide/index.html
- ASA GAISE Reports: https://www.amstat.org/education/guidelines-for-assessment-and-instruction-in-statistics-education-%28gaise%29-reports
The explanations, tables, and synthetic data generation rules in this topic are educational material independently written by BioStatPy. They do not reproduce the sentences, expressions, or example arrangements of external sources.