04

Data Scientist · Step 4 of 8 · 12 min

Probability and statistics for decisions

Read a confidence interval, a p-value and an A/B test result without overclaiming.

Samples and uncertainty

You almost never see everyone. You see a sample: the customers who answered a survey, the visitors during one week. Any number from a sample would come out a little different with another sample. Statistics is mostly the craft of saying how sure you can be, given that wobble.

Bigger samples wobble less, but a big sample collected in a biased way is still biased. Ten thousand survey answers from only your happiest users tell you about your happiest users.

Confidence intervals in plain words

A confidence interval gives a range instead of a single number. “Average order value is 42, with a 95% interval from 39 to 45” means the method used tends to produce ranges that contain the true value about 95% of the time. A wide interval is an honest way of saying “we do not know very precisely yet”.

When you report a result, give the range. Decision-makers handle uncertainty better than you might expect, and much better than a false sense of precision.

p-values and their limits

A p-value answers a narrow question: if there were truly no effect, how surprising would data like ours be? A small p-value, often below 0.05, says the data would be fairly unusual under “no effect”. It does not tell you the chance your idea is true, and it says nothing about whether the effect is big enough to matter.

Test enough things and some will look significant by luck. Decide what you will test before you look, and report effect sizes, not just p-values.

A/B tests and Simpson's paradox

An A/B test randomly splits people between two versions and compares an outcome. Randomness is the key: it makes the groups alike in everything except the change, so the difference can be credited to the change. Decide the sample size and the metric in advance, and do not stop early the moment it looks good.

Simpson's paradox is a warning about combining groups. A treatment can look better in every subgroup yet worse overall, if the groups differ in size and mix. Always ask whether a hidden variable is shaping the total.

Try it

Interrogate an A/B result with a chatbot

  1. 1.Paste the prompt below into a chatbot, filling in made-up or real numbers.
  2. 2.Ask it to show the calculation in Python, then run that code in Colab to check it.
  3. 3.If the chatbot's numbers and your code disagree, trust the code and find out why.
I ran an A/B test. Version A: [VISITORS_A] visitors, [CONVERSIONS_A] purchases. Version B: [VISITORS_B] visitors, [CONVERSIONS_B] purchases. Explain in plain words whether B is better, give a 95% confidence interval for the difference, say what the p-value does and does not mean here, and list three things that could make this result misleading.
A test gives p = 0.03 for a new checkout button. Which statement is correct?

Check yourself

A test gives p = 0.03 for a new checkout button. Which statement is correct?

Read alongside