انتقل إلى المحتوى
لندن، المملكة المتحدة · تأسست عام 1994
العربية

Unit 3: Statistical Thinking and Inference

How to reason from samples to wider populations, express uncertainty honestly, interpret tests correctly and tell the difference between correlation and causation.

Unit 3 of 5 · about 54 minutes

3.1 Samples, populations and bias

We rarely have data on everyone or everything we care about. Instead, we usually have a sample and want to draw conclusions about a wider population. This process of reasoning from a sample to a population is called statistical inference. It is powerful, but only when the sample is collected and interpreted with care.

Key terms

  • Population: the whole group you want to understand, such as all current customers, all patients with a condition, or all products made in a year.
  • Sample: the subset you actually observe or measure.
  • Parameter: a true value for the population, such as the actual proportion of all customers who are satisfied. It is usually unknown.
  • Statistic: a value calculated from the sample, such as the proportion of surveyed customers who said they were satisfied. It is used to estimate the parameter.

Random sampling

The most reliable way to obtain a sample that represents the population is random sampling, in which every member of the population has a known chance of being selected. A simple random sample gives every member an equal chance. A stratified sample divides the population into groups, such as regions, and samples randomly within each, ensuring that every group is represented.

Random sampling does not guarantee that a particular sample is perfectly representative. It does mean that differences between sample and population arise by chance rather than by systematic bias, and chance variation can be measured and allowed for, as the next lesson explains.

Sampling variability

If you took several different random samples from the same population, each would give a slightly different result. This natural variation is called sampling variability. Larger samples vary less, so estimates from them are more precise. However, precision increases more slowly than sample size: to halve the typical sampling error you need roughly four times as many observations.

Bias: the bigger danger

Bias is a systematic difference between what the sample shows and the truth about the population. Unlike random variation, bias does not shrink as the sample grows. A huge biased sample can be confidently wrong. Common forms include:

  • Selection bias: the way the sample is chosen excludes or over-represents certain groups. An online survey misses people who rarely go online.
  • Non-response bias: the people who respond differ from those who do not. Customers with strong opinions, positive or negative, are often more likely to complete feedback forms.
  • Survivorship bias: only the "survivors" of a process are observed. Studying only businesses that are still trading ignores the lessons of those that closed.
  • Measurement bias: the way data is recorded distorts it, for example a leading survey question or a faulty sensor.
  • Convenience sampling: using whatever data is easiest to obtain, such as the customers who happen to contact the help desk, who may differ greatly from the customer base as a whole.

Remember: a large sample reduces random error but does nothing to fix bias. Always ask who or what is missing from the data, and why.

Data you did not design

Much data science uses observational data collected by business systems for operational reasons, not designed samples. Such data can be very large, but it reflects whoever happened to use the service, in the way they happened to use it. Before generalising, ask how the data came to exist. For example, website analytics describe visitors to the website, not the wider market; complaints data describes people who complained, not everyone who was dissatisfied.

Common mistakes

  • Treating a big dataset as automatically representative.
  • Generalising from one region, period or customer segment to all of them.
  • Ignoring low response rates in surveys.
  • Forgetting that the population may have changed since the data was collected.

In practice

For a dataset or survey you use, write down the population you want to understand and the sample you actually have. List who might be under-represented or missing and how that could affect the conclusions. If you are planning a survey, consider how you will select participants, how you will encourage responses from people who are less likely to reply, and how you will compare respondents with the known characteristics of the population to check for obvious imbalances.

3.2 Uncertainty, confidence intervals and hypothesis tests

Because samples vary, any estimate from a sample comes with uncertainty. Good data science makes that uncertainty visible rather than presenting a single number as if it were exact. This lesson introduces two widely used tools, confidence intervals and hypothesis tests, focusing on how to interpret them correctly rather than on the formulas behind them.

Standard error

The standard error measures how much an estimate, such as a sample mean or proportion, would typically vary from one random sample to another. It gets smaller as the sample size grows and larger when the data itself is more variable. It is the building block for both confidence intervals and many tests.

Confidence intervals

A confidence interval gives a range of plausible values for a population parameter. Suppose a random sample of customers gives an average satisfaction score of 7.2 out of 10, with a 95% confidence interval from 6.9 to 7.5. This means that the method used to produce the interval would, over many repeated samples, capture the true population average about 95% of the time.

In practical terms, the interval tells you how precisely the sample pins down the true value. A narrow interval indicates a precise estimate; a wide one indicates considerable uncertainty. Comparing intervals is often more informative than comparing single numbers: if two regions have average scores of 7.2 and 7.5 but each interval is wide and they overlap heavily, the apparent difference may simply reflect chance.

Hypothesis testing

A hypothesis test assesses whether the data provides evidence against a default assumption. The default, called the null hypothesis, usually states that there is no effect or no difference, for example that a new website design produces the same conversion rate as the old one. The alternative hypothesis states that there is a difference.

The test produces a p-value: the probability of seeing a result at least as extreme as the one observed, if the null hypothesis were true. A small p-value means the observed data would be surprising if there were really no effect. By convention, many fields treat p-values below 0.05 as "statistically significant", though this threshold is arbitrary.

What p-values do not tell you

P-values are frequently misunderstood. A p-value:

  • is not the probability that the null hypothesis is true;
  • does not measure the size or importance of an effect;
  • does not show that a result is meaningful for the business.

With a very large sample, tiny and unimportant differences can be statistically significant. With a small sample, a large and important effect may not reach significance. That is why the effect size, how big the difference is, and its confidence interval should always be reported alongside any test.

Tip: when you see "statistically significant", ask two questions: how large is the effect, and how uncertain is that estimate? "Significant" in statistics does not mean "important".

Two kinds of error

Tests can go wrong in two ways. A Type I error (false positive) concludes there is an effect when there is none. A Type II error (false negative) misses an effect that really exists. The chance of detecting a real effect is called the test's power, which increases with sample size and effect size. Planning sample size in advance helps ensure a study is capable of detecting effects that matter.

The problem of many tests

If you run many tests, some will produce small p-values by chance alone. At a 0.05 threshold, roughly one in twenty tests of effects that do not exist will appear significant. Searching through dozens of comparisons and reporting only the "significant" ones, a practice sometimes called p-hacking or data dredging, produces misleading findings. Decide in advance which comparisons matter, report all the tests you ran and treat surprising results as ideas to be confirmed with new data.

In practice

When you present an estimate, include a measure of uncertainty, such as a confidence interval or a plain statement like "between 6.9 and 7.5". When someone presents a significant finding, ask for the effect size, the sample size and how many comparisons were made. Encourage your team to describe results in practical terms, for example "the new design increased conversion by between 0.2 and 0.8 percentage points", which supports far better decisions than a bare p-value.

3.3 Correlation, causation and experiments

Many of the most important business questions are about cause and effect. Did the marketing campaign increase sales? Does the new training reduce errors? Would a price change reduce demand? Data can show that two things move together, but establishing that one causes the other requires more care. This is one of the most important ideas in data science.

Why correlation is not causation

Two variables can be correlated for several reasons other than one directly causing the other.

  • Confounding: a third factor influences both. Ice cream sales and sunburn cases rise together, not because ice cream causes sunburn, but because both increase in hot, sunny weather.
  • Reverse causation: the cause runs the other way. Areas with more police officers may have more recorded crime, partly because more officers are deployed where crime is high.
  • Selection effects: the way data was gathered creates a pattern. If only customers who stayed long enough to complete training are studied, training will appear linked to loyalty.
  • Chance: with enough variables, some will be correlated by coincidence.

Simpson's paradox

Sometimes a pattern seen in combined data reverses when the data is split into groups. Imagine two hospitals. Hospital A has a higher overall death rate after surgery than Hospital B. But Hospital A treats far more high-risk patients. Within both the low-risk and high-risk groups, Hospital A actually has the better outcomes. The overall comparison was misleading because patient risk was a confounder. This effect, known as Simpson's paradox, shows why comparisons should consider relevant subgroups.

Randomised experiments

The most reliable way to establish causation is a randomised controlled experiment. Participants or units are randomly assigned to a treatment group, which receives the change, or a control group, which does not. Because assignment is random, the groups should be similar in every respect except the treatment, on average. Any substantial difference in outcomes can therefore be attributed to the treatment, subject to the usual uncertainty.

In digital businesses, randomised experiments are often called A/B tests. Visitors to a website are randomly shown version A or version B of a page, and outcomes such as sign-ups are compared.

Running a good A/B test

  1. Define the primary measure in advance, such as conversion rate, and any important "guardrail" measures that must not get worse.
  2. Estimate the sample size needed to detect the smallest effect that would matter.
  3. Randomise properly and check that the groups look similar at the start.
  4. Run for the planned duration, covering full weekly cycles, rather than stopping as soon as the result looks good.
  5. Analyse and report honestly, including effect size, uncertainty and any unexpected effects.

Tip: stopping an experiment early because the result looks significant is a common way to produce false positives. Decide the duration in advance and stick to it.

When experiments are not possible

Randomised experiments are sometimes impractical, unethical or too expensive. You cannot randomly assign people to smoke, or randomly close some branches just to learn something. In such cases, analysts use observational methods that try to approximate an experiment. Examples include comparing similar groups before and after a change, where one group was affected and another was not (an approach called difference-in-differences), and statistically adjusting for known confounders. These methods can be valuable, but they rely on assumptions that should be stated clearly, and their conclusions are usually less certain than those of a well-run experiment.

Common mistakes

  • Claiming a campaign "caused" an increase in sales without considering seasonality or other changes at the same time.
  • Comparing people who chose to take part in a programme with those who did not, ignoring that they may differ in important ways.
  • Running many variations of an A/B test and reporting only the best.
  • Ignoring results that contradict expectations.

In practice

Next time you hear a claim that one thing caused another, ask: what else changed at the same time? Could the cause run the other way? Who chose to be in each group? If your organisation is considering a change that can be tested, such as a new email format or a revised form, propose a small randomised test with a pre-agreed measure and duration. Even simple experiments can give much stronger evidence than before-and-after comparisons.

Case study: Testing a new reminder letter at a dental practice group

Brightsmile Dental Group, a fictional chain of practices, was concerned about missed appointments. The operations manager noticed that patients who received text reminders missed fewer appointments than those who did not, and proposed sending texts to everyone.

The group's analyst pointed out a likely confounder: patients who had given a mobile number tended to be younger and more engaged, and might attend more reliably anyway. To find out whether reminders themselves made a difference, the group ran a randomised test. Over eight weeks, patients with mobile numbers were randomly assigned either to receive a text two days before their appointment or the standard letter alone.

The team agreed in advance that the main measure would be the proportion of missed appointments. At the end, the text group missed somewhat fewer appointments, and the confidence interval for the difference excluded zero, though it was wider than hoped. The analyst presented the estimated range of benefit and its cost. The group adopted text reminders and continued tracking results to check the effect held.

Activity

Find a claim in your organisation or in the news that one thing caused another. Identify at least two alternative explanations for the observed relationship. Then outline a simple randomised experiment, or the best available alternative, that could test the claim more convincingly.

Compare with a model answer

A good answer states the claim clearly, for example "staff who attended the wellbeing workshop took fewer sick days afterwards". It offers realistic alternative explanations: staff who chose to attend may already have been healthier or more engaged (selection), and sick days may have fallen generally over the same period because of the season (confounding by time).

It then proposes a better test. A randomised design might offer workshop places to a randomly chosen half of teams first, comparing sick days between the groups over the same period. If randomisation is not possible, the answer suggests comparing changes in attenders and similar non-attenders before and after, while acknowledging the remaining uncertainty. Strong answers specify the measure and duration in advance.

Key takeaways

  • Statistical inference reasons from a sample to a population, and random sampling allows chance variation to be measured.
  • Bias is a systematic error that larger samples do not fix, so always ask who or what is missing from the data.
  • Confidence intervals show how precisely a value is estimated, and should accompany any important estimate.
  • A p-value is not the probability that a hypothesis is true, and statistical significance does not mean practical importance.
  • Correlation can arise from confounding, reverse causation, selection or chance; randomised experiments are the strongest way to establish causation.

Unit check

Create a free account to answer the check, save your progress and receive your free certificate.

Create a free account Log in
← Unit 2 Unit 4 →
WhatsApp