FE0 1
Introduction to Probability
Every lesson so far, in one document · 2 chapters
Lesson 1
Introduction to Statistics
Taught
What is Statistics
Statistics gives meaning to data, or better, it is the science of drawing conclusions from data. It is used in a great many parts of life:
- Predicting. Using what has already happened to say something about what has not: elections, weather, the price of an asset.
- Contextualising. Placing a number beside the numbers that make it meaningful, which is most of what economics, politics and business reporting consists of.
- Gathering. Designing the collection of new data so that it can support a prediction at all. Medicine, marketing, finance and the social sciences all depend on experimental design, and without well-gathered data the other two uses are worth little.
Scrutinising a Claim
Consider a study of microplastics in bubble tea sold in the Bay Area, which reported dangerously high levels of BPA and microplastics in the drinks.
Faced with a result like this we already have ideas about where the plastic came from. Perhaps it is the straws. Perhaps it is the containers the drink is served in. Whatever the guess, it has to be scrutinised, because one possibility is always that the effect arose by chance rather than from the cause we have in mind.
Definition 1.1 (Null Hypothesis).
The null hypothesis is the claim that the pattern in the data arose by chance: that the supposed cause has no effect. A study is an attempt to gather evidence against it.
In this case the tap water used to prepare the drinks was itself already carrying a high concentration of microplastics, and tap water is used at every stage, from boiling the tapioca to making the syrup. Once that is known, the cup and the straw stop looking like the main source: the drink was made from contaminated water before it ever met a container.
Remark.
That finding was not in the headline, nor the subheadline. It appears as a passing remark inside the article. Often the detail that most changes the meaning of a result is not the one the article is written around.
The evidence points at the tap water rather than at the cup or the straw. Describe a measurement which would settle the question, and say what it would show if the cup really were the main source. Then say why the headline is still a fair description of the result and a misleading one.
Gathering New Data
How does one gather new information to answer a hard question? In medicine two designs are standard.
- In an observational study the researchers watch what happens without intervening. Its aim is to find a cause and its effect as they occur naturally.
- In a randomised double-blind trial the researchers assign the treatment themselves, at random, and neither the patient nor the researcher knows who is receiving the drug and who the placebo. Its aim is to remove bias.
The difference in aim matters. An observational study can tell us what happens in the world as it is; a randomised trial can tell us what the treatment does, because randomisation removes the link between receiving the treatment and everything else about the patient.
A third design, familiar outside medicine, is A/B testing: users are assigned at random to group A or group B, each group is shown a different version of something, and the versions are compared on whatever response we care about. Advertising a new phone one way or another way is decided this way.
Example 1.2 (The Salk polio trial).
The 1954 trial of the Salk polio vaccine had to overcome a difficulty which had nothing to do with the vaccine. The vaccine was of the killed-virus kind, which carries a smaller risk than a live one but also, at that time, a less certain benefit, and a great many parents refused to let their children take part.
The refusal was not evenly spread. Consent to take part was more common among wealthier, more educated families, and polio incidence was higher in wealthier and more hygienic areas, since children in cleaner surroundings met the virus later, when it does more damage. So comparing children who were vaccinated with children who were not would have compared two groups differing in far more than the vaccine, and in a direction that would have made the vaccine look worse than it was.
Consider the polio trial described above.
- What makes designing a trial for this vaccine difficult, beyond the medicine?
- How would you design one? Say which of the two designs above you would use and what your design does about the fact that consent is not evenly spread across the population.
Prediction
The third use is prediction. Given the data available to us, we want the likely outcome: how risky a stock is, what it is likely to be worth, how much of a portfolio to put in it. Much of the rest of this course is about doing that carefully.
How Statistics Goes Wrong
A statistic can be true and still mislead, if it answers a different question from the one being asked.
Example 1.3 (Two true statements).
At the trial of O. J. Simpson the defence noted that fewer than in women who are abused by their partner are later murdered by that partner. The number is correct, and it is an answer to the question “given that a woman is abused, how likely is she to be murdered by her abuser?”
That was not the question before the court. The victim had already been murdered, and the relevant figure is that about out of abused women who are murdered are murdered by their partner. Conditioning on what is already known changes the answer completely, and a later lesson explains why.
The second failure is one of procedure rather than arithmetic.
-hacking is the practice of searching a body of data for patterns and then reporting whichever pattern is found as though it had been predicted in advance. Because a large enough search finds apparent effects in data with no effect in it, the reported finding may be a false positive produced by the search itself.
The order matters. Form the theory, then collect data to test it. Collecting data first and looking for patterns afterwards risks finding a pattern that is not there.
What is the difference between forming a hypothesis and then collecting data, and collecting data and then forming a hypothesis? Say what goes wrong in the second order, and give an example of a claim you would distrust for this reason.
Numbers in Context
A number on its own is not informative. It becomes informative when we compare it with a baseline, and choosing the baseline is the hard part.
Is $10 billion a lot of money? As a person’s net worth, yes. As a country’s annual output, no.
To talk about a number at all we put it through three filters.
- What kind of number is it? Is it a rate, a percentage, a nominal amount, an average? How was it calculated, and who is reporting it?
- What can it be compared with? Is there a natural baseline or denominator? Can it be compared with the past? What is missing that the comparison would need?
- Is it plausible? Is it surprising, or is it about what we should have expected?
Example 1.5 (Traders who lose money).
A widely repeated figure is that between and of day traders lose money.
What kind of number is it? A percentage, which raises at once the question: a percentage of what? The figure traces back to a study of Taiwanese day traders, in which a trader counts as having quit after twelve consecutive months without a trade, and profitability is estimated from a model rather than observed directly. Both of those choices affect the number. Who reports it matters too: it usually reaches the reader through an investment article rather than the paper.
What can it be compared with? One comparison is with someone who put the same money into government bonds, another with someone who bought a broad index and left it alone. Neither is a like-for-like comparison, since neither involves trading at all, and both still give a usable picture of what the activity costs.
Is it plausible? For anyone who has traded, only mildly surprising.
Example 1.6 (Student loan debt).
Education Data Initiative reports that the average federal student loan debt balance is $38,375.
What kind of number is it? An average, and immediately: an average of what, over whom? Averaged over borrowers, or over the whole population? Does it include recent graduates, or people who finished twenty years ago? Does it count medical debt, or international students? Is it a poll, a survey, or a figure taken from government and banking records?
Is it representative? The state figures spread widely around it.
| State | Average borrower debt |
|---|---|
| Maryland | $43,692 |
| California | $38,168 |
| North Dakota | $29,279 |
Source: Education Data Initiative
What can it be compared with? What the money buys, what a degree costs elsewhere in the world, the salary it leads to, the salary without it, and the interest accruing on the balance. The last of these are missing, and a debt figure without the earnings it bought is only half a comparison.
Is it plausible? Set against a well-known American university charging on the order of $71,000 a year, a lifetime balance of $38,375 is a good deal lower than one might expect, which is itself a hint that the average is being taken over a wider group than one first imagines: not only recent graduates of expensive private universities, but everyone still carrying a federal balance.
Remark.
Both of the questions asked of the average, whether it represents the population and how far the extremes lie from it, are questions about variability. We formalise it later in the course.
In 2022 there were fatalities from car accidents in the United States.
- What kind of number is it?
- What can it be compared with? Give at least two baselines, and say what each one would tell you that the other would not.
- What would you have expected the number to be?
Ball-park Estimates
Most of the time the number we want for the baseline is not to hand. The fix is to estimate it: split the quantity into smaller pieces we can each guess at, guess each piece, and multiply. Working to the nearest power of ten keeps the arithmetic easy and is usually accurate enough to settle the question.
Example 1.7 (Food stamp fraud).
A case study describes an article reporting that fraud in the American food stamp programme is at an all-time high, costing taxpayers $70 million, and using this to argue for ending the programme.
Is $70 million a big number? Not until we know what to compare it with, and the natural comparison is the size of the programme. That figure is not in the article, so we estimate it:
Take million people. Take one in ten receiving, by analogy with the share of the population using food banks in the UK. For the third factor take $150 a month, roughly what a single person receives on universal credit for food, so $1800 a year. Then
about $54 billion, which makes the reported fraud
The actual budget in 2016 was , so our estimate was within of it, and the conclusion does not depend on the difference: the fraud is a fraction of one per cent either way.
Remark.
Estimating a number from limited information this way is called a Fermi problem, after Enrico Fermi, who was fond of such questions.
- Hours a year an Imperial student spends on problem sheets:
- Money spent on university tuition in the United States each year:
- The circumference of the Earth in miles. The metre was originally defined as one ten-millionth of the distance from the pole to the equator, so that distance is km and the circumference is km. At km to the mile that is miles, against a true value of about .
Give a ball-park estimate for each of the following, setting out the factors you multiply and the guess you make for each.
- How many pet dogs are there in North America?
- How many hours a year does the average American spend sitting in traffic?
- What would it cost to pay the tuition, room and board of every Imperial undergraduate for one year? What fraction of the College endowment is that, and what would you need to know to decide whether that fraction is large?
Cost-Benefit Analysis
Ball-park estimates are most useful when a decision depends on them. Faced with a choice between and :
- estimate the cost of each;
- estimate the benefit of each;
- choose the more attractive;
- if the stakes are high, ask how robust the analysis is.
The first two steps are Fermi problems. The fourth asks which inputs we are least sure of, and whether the conclusion survives varying them.
Example 1.9 (Cutting a fleet's fuel bill).
Fuel is one of the largest operating costs of a freight company and one of the most volatile, and it drives maintenance spend, vehicle downtime and emissions liabilities with it.
You are the capital allocation lead at a mid-sized trucking firm. You have a one-off capital budget of $10 million to cut fuel costs across a fleet of trucks the company already owns, and you must choose between two options.
- Fleet replacement. Buy new fuel-efficient tractors to replace the oldest vehicles in the fleet. A truck delivers its efficiency gain only once it has been bought outright and put into service; there is no partial version.
- Retrofit and driver programme. Fit the existing trucks with aerodynamic side skirts, and install telematics which score drivers and coach them on fuel-efficient driving. Fuel burn falls appreciably when drivers follow the coaching.
Before reading on: given only what is written above, which would you choose, and why?
The benefits. Both options promise the same kinds of thing: less volatility in the fuel bill, lower operating cost, lower maintenance spend, more vehicle uptime, less exposure to emissions liabilities, and for the new tractors a resale value at the end. Quantifying all of those separately is more than the decision needs. Money saved per year captures most of it and is the one we shall use.
The costs. These also come in kinds: the money spent upfront, the driver time spent in training rather than driving, the installation or contracting work, and the telematics subscription each year. Two of those are upfront and one is annual, so we quantify cost as
Quantifying the benefit. First estimate what one truck burns:
and at $1.20 a litre that is $42,000 of fuel per truck per year.
For the retrofit, side skirts cut burn by about , worth $2,100 a year. Telematics cut it by about , but only about of drivers follow the coaching, so call it and another $2,100. That is $4,200 saved, less the $600 annual subscription, so about $3,600 per truck per year.
For a new truck, burn falls from to L per km, a fifth less, worth $8,400 a year, and maintenance on a new truck is about $6,000 a year lower. That is about $14,400 per truck per year.
Quantifying the cost. Retrofitting costs about $3,500 per truck upfront, side skirts and telematics installation together, and $600 a year after for the subscription. A new tractor costs $150,000, against $30,000 for the old one sold, so $120,000 upfront and nothing thereafter.
The comparison. Payback is upfront cost divided by net yearly saving:
The budget buys either of two things. Retrofitting the whole fleet costs and saves a year. Replacing trucks buys of them for the full million and saves a year. So the retrofit saves more while spending under a fifth as much, and it leaves most of the budget unspent.
Robustness. The inputs we are least sure of are the price of diesel, the share of drivers who follow the coaching, the fleet size and the maintenance saving. Varying any of them within a plausible range does not reverse the conclusion, because the two options differ by a factor rather than a few per cent.
Take the fleet example above over a ten-year horizon, and suppose the budget stays at $10 million.
- Show that no value of the driver compliance rate, however low, makes the new trucks the better choice. Say which feature of the two options makes this so.
- The retrofit cost of $3,500 per truck is the input a supplier could most easily change. How high would it have to go before the new trucks won? Remember that once it rises above $20,000 the budget no longer covers the whole fleet.
Exploratory Data Analysis
Much of what probability is for is saying something about a whole group when we have only seen part of it.
Definition 1.10 (Population and Sample).
The population is the entire collection of units we want to draw a conclusion about. A sample is a subset of the population which we actually observe.
Old Faithful is a geyser which erupts roughly an hour apart. Asking how faithful Old Faithful is means asking about every eruption it will ever make, from the few hundred that have been timed.
Or take an election with voters choosing between A and B. We cannot ask all of them. Coding a vote for A as and for B as , a sample of voters splitting to gives some idea of how the whole electorate will divide.
Remark.
Nothing so far guarantees that what holds in the sample holds in the population. The rest of the course is about making that step safely.
Returns
Take a financial example. The monthly equity returns for Canada were recorded over months, from February 1988 to December 1996, one number per month.
0.07 0.05 0.02 -0.04 0.08 -0.02 -0.05 0.02 0.03
0.00 0.03 0.08 -0.03 0.01 0.03 0.01 0.02 0.08
0.02 -0.02 0.00 0.01 0.02 -0.09 0.00 0.01 -0.07
0.07 0.00 0.02 -0.05 -0.04 -0.03 0.03 0.04 0.00
0.07 0.00 0.01 0.04 -0.02 0.02 0.01 -0.03 0.05
-0.02 0.00 0.01 -0.01 -0.05 -0.01 0.01 0.00 0.02
-0.02 -0.07 0.03 -0.04 0.03 -0.02 0.06 0.03 0.04
0.01 -0.01 -0.01 0.01 -0.05 0.09 -0.02 0.05 0.06
-0.05 -0.04 -0.01 0.01 -0.06 0.05 0.06 0.02 -0.01
-0.06 0.02 -0.05 0.06 0.04 0.02 0.04 0.02 0.02
0.00 0.00 -0.01 0.04 0.01 0.05 -0.01 0.02 0.04
0.02 -0.03 -0.03 0.05 0.04 0.08 0.07 -0.03
A first question to ask of a column of numbers like this is where the middle is.
Scanning it, the values look as though they tend positive, and that is what we should expect. An asset whose returns averaged zero would go nowhere over the nine years, and one whose returns averaged negative would end the period worth less than it started, which is not what these equities did. So the middle is somewhere above zero. Reading a column one entry at a time is a poor way to locate it, though, and the first thing to do with data like this is draw it.
For an asset held over a period, beginning at value and ending at value , the return over the period is
and is the factor of return, so that .
If an asset ends the period at having returned , then , so .
Remark.
What counts as the ending value depends on the asset. For a share held and sold it is the sale price, but if the share paid dividends over the period those belong in too, since they are part of what holding it returned.
Histograms
To see a column of numbers we plot it. The values are sorted into bins, and the number of values falling in each bin is drawn as a bar.
Reading it: the centre sits somewhere between and , the shape is a single mound with the two tails dying away at roughly the same rate, and nothing sits far out on its own. The most common outcome is a small positive month.
Remark (A histogram is not a bar chart).
Histograms are for quantitative variables and bar charts are for categorical ones. The vertical axis of a bar chart may be anything; the vertical axis of a histogram is always a count or a frequency.
Remark.
The number of bars changes how smooth the picture looks. Too few and the shape disappears into three or four blocks; too many and every bar is a count of one or two, and the shape is lost in the noise.
Not every set of data makes a symmetric mound. A distribution is skewed to the left when its left tail is drawn out, which puts the bulk of the values on the right, and skewed to the right when the right tail is the long one.
The spread of the values about the centre is the variation. In the Canadian returns it could come from almost anything: credit conditions, commodity prices, a change of policy, a single piece of news. Naming the sources is not the same as measuring the spread, and measuring it is what we do later.
Data, Units and Variables
Definition 1.14 (Data, Observational Units, Variables, Distribution).
Data are the values measured, or the characteristics recorded, on the individual entities of interest.
The observational units are those individual entities on which the data are recorded.
The variables are the measured values or recorded characteristics of the observational units. A variable is quantitative if its values are numbers, such as a height or a return, and categorical if its values are labels, such as a country or a vote.
The distribution of a variable is the pattern of its values across the observational units: which are common, which are rare, and how widely they spread.
A histogram is not the only way to draw a distribution. A dot plot puts one dot per observation above its value, stacking them where values repeat, which keeps every individual observation visible in a way binning does not.
For the example above, the observational units are the individual months, the variable is the return , which is quantitative, and Figures 1.1 and 1.3 are two pictures of its distribution.
Remark.
To work out what the observational units are, it helps to ask first what variables are being measured. The units are whatever each measurement is attached to.
For each study, state the observational units and name two relevant variables, saying for each whether it is quantitative or categorical.
- A study of what makes pairs of college room-mates compatible.
- A study of the availability of vegetarian meals in the College dining halls.
A 2003 study titled Do defaults save lives?, published in Science, investigated whether the phrasing of the sign-up question affects how many people register as organ donors. The participants filled out a fake online driver’s licence application, and were asked to sign up in one of three ways: opt-in, told the default was not being a donor; opt-out, told the default was being a donor; and neutral, not told about any default and asked to choose.
- What are the observational units?
- What are the variables, and are they quantitative or categorical?
Comparing Distributions
Put a second country beside the first. Japanese equity returns were recorded over the same months, and here is each country drawn on the axes that suit it.
Set side by side like this the two pictures say almost nothing. Both show a mound near zero of roughly the same width on the page, so the eye reports that the two countries behave alike. They do not: the horizontal axes differ by a factor of two, and the bins differ with them, so equal-looking widths on the page stand for quite different widths in returns. The vertical axes can play the same trick.
Always check the axes before comparing two histograms, and if they differ, redraw. Here are the two on one scale.
Read together, the two show something a single number would not. The Canadian returns run from to ; the Japanese run from to . Japan’s tails reach much further in both directions, so it offers both the larger gains and the larger losses, while Canada clusters more tightly about its centre.
Remark.
Which is better depends on what is wanted, and the histograms do not answer it. A tighter distribution carries less risk but gives up the larger gains. That trade-off is the subject of a later part of the course.
Outliers
An outlier is a value lying far from the bulk of the data. Two cohorts of sixty students were each asked how many hours a week they spend on problem sheets; here are the answers, on one pair of axes. The figures are made up for the purpose, so that the shape being discussed is unmistakable.
The lone bar near hours in cohort B is an outlier. Everything else in that cohort lies below , so a single student sits more than twice as far out as anyone around them.
Comparing the two, the general claim is available: cohort A works more, because its centre sits at larger values, near hours against cohort B’s . The outlier does not disturb that claim, and it does move a summary. Cohort B’s mean is hours with the outlier and without it, so one student out of sixty shifts the average of the whole cohort by nearly three quarters of an hour.
An outlier is not automatically an error to be removed. It may be a mistake in recording, in which case it should go; it may be a student who genuinely works that way, in which case it is the most informative observation in the set. Deciding which requires knowing where the number came from, and that is a question about the data collection rather than about the histogram. The same applies to Japan’s two months below in Figure 1.7: they sit clear of the mound, and any summary of the Japanese returns which throws them away will understate how badly a month can go.
Time Series
The returns above were collected over time, and they came in an order. A histogram throws that order away.
Definition 1.15 (Time Series).
A sequence of observations recorded over time, in the order they occurred, is a time series. Plotting the observations against time gives the time series plot.
The vertical axis carries the return and the horizontal axis the time, so each point is one month and the line joins them in the order they occurred.
Look at Figure 1.10. Do you see a pattern? Say what a run of consecutive months above zero would have to look like before you would call it one.
It is tempting to read this plot as returning towards zero after each excursion, or as being about to turn after a run in one direction. Neither is visible here. The series is close to what repeated coin tossing looks like when it is plotted, and one of the things this course does is give us the means to say what “close to” means, rather than deciding by eye.
Not every series is like that.
Source: monthly beer production in Australia, monthly observations running from January 1956 to August 1995. The figure shows the last four and a half years.
Does the series in Figure 1.11 have a pattern? If it does, say what it is, at what points the series peaks and at what points it falls, and what could produce it. The data are Australian.
The pattern repeats once a year, and knowing it changes the question to ask. The interesting thing about any single month is no longer how large it is, but how large it is beside the same month in other years, since comparing a peak month with a trough month tells us about the calendar rather than about the brewing.
Remark.
The vertical axis matters here as much as the data. A plot whose axis starts well above zero makes a small wobble look like a crisis, and one whose axis runs far past the data flattens a real movement into a straight line. Check the axes first, on your own plots as much as on other people’s.
Exercises
Decide whether each of the following is true or false, and support your answer with a ball-park estimate rather than a search.
- More than million gallons of milk are consumed in London each year.
- I could empty an ornamental fountain in one day using only a teaspoon.
- Imperial students collectively buy many thousands of textbooks each year.
Set up a Fermi-style calculation for the benefit and for the cost of distributing insecticide-treated mosquito nets, using the following.
- An unvaccinated child in sub-Saharan Africa has to malaria infections a year in early childhood.
- The infection fatality rate is about death per clinical cases.
- A net costs $2 to manufacture, stays effective for about years, and is shared by people on average.
- People sleeping under a net are half as likely to contract malaria as those without.
Give the benefit as deaths averted per person-year and the cost as dollars per person-year.
Do the same for a vaccination campaign, using the following.
- The vaccine works best if the first dose is followed by a booster years later, and children receiving both doses are to less likely to die of malaria. Assume children receiving only one dose see no change.
- Only of children who get one dose return for the booster, so about doses are given per fully vaccinated child.
- A single dose costs $10, and the vaccine must be kept cold and administered by a trained professional.
Give the cost per death averted for each of the two programmes above. Which is the better use of a fixed budget, and by roughly what factor? Are you surprised? Say which components of your calculation you are least confident in, and whether the conclusion survives varying them.
Take the state figures for average student loan debt given earlier.
- The national average is $38,375 and California’s is $38,168. Explain why these being close does not mean California is typical.
- Name a number not in the table which would change your reading of the national average, and say in which direction.
A newspaper reports that a treatment “doubles your risk” of a disease.
- What kind of number is this, and what is missing?
- What would you need to know before deciding whether to act on it?
- Give a baseline risk for which the doubling would matter, and one for which it would not.
Sketch, by hand, the histogram you would expect for each of the following, and say whether it is roughly symmetric, skewed to the left, or skewed to the right.
- The heights of adults in a large city.
- The annual incomes of households in a large city.
- The marks of a cohort on an examination that most of them found easy.
Figure 1.1 uses one bin per percentage point, and its tallest bar is the months returning .
- Redraw the histogram in your head with bins of percentage points. How many bars are there, and what happens to the shape?
- Redraw it with bins of a tenth of a percentage point. What goes wrong?
- State in one sentence what the bin width is trading off.
Check Yourself
Fresh questions on the whole lesson — none of them is worked out above. Do each on paper first; the box only tells you whether you got there.
Answers are checked in your browser, as often as you like. Nothing is sent anywhere and
nothing is kept but your own work. A formula may be written with the symbols themselves or
with ~ & | -> <-> ^, and \and, \or, \to expand as you type.
The claim that a pattern in data arose by chance, and that the supposed cause has no effect, is called the
Researchers assign a treatment at random, and neither the patient nor the researcher knows who received the drug. This design is a
Searching a body of data for patterns and then reporting whichever is found as though it had been predicted is called
A histogram is the right picture for which kind of variable?
The vertical axis of a histogram is always
A distribution whose right tail is drawn out far past the bulk of its values is
The country of birth is recorded for each student in a cohort. This variable is
In the Canadian returns data, what are the observational units?
An asset begins a period at and ends it at . What is the return?
An asset begins at and returns over the period. What is ?
Canadian monthly returns run from to and Japanese from to over the same months. Which has the greater variation?
A value lying far from the bulk of the data is called
To the nearest power of ten, how many seconds are there in a year?
Reported fraud of $70 million against a programme budget of about $54 billion is roughly
Which plot keeps the order in which the observations were recorded?
Lesson 2
Summarising Data
Taught
Measures of Central Tendency
Suppose we collect pieces of data. We need some way of describing them, and we write them as
Here is the first number and the last, and is the number of numbers, the number of observations, also called the sample size. These are the values we observe. The letter is just a name for the set of numbers; we could just as easily use . If the data are , for example, then , and .
Sometimes the order of the observations means something. In the monthly returns of the last lesson the first observation corresponds to the first month. Sometimes it does not: in a survey each number corresponds to one respondent, and the list could be written in any order.
The Sample Mean
The sample mean of is their average,
The symbol is read ” bar”.
There is a more compact way to write the sum , called summation notation:
It means that for each value of from to we add to the sum the value indicated, in this case . Using it,
For the data the mean is .
Example 2.2 (Summation notation).
Think of each row of this table as an observation on two variables. To make things concrete, each row is a year, and and are the annual returns on two different assets: in year asset returned , and in year asset returned .
| year | ||
|---|---|---|
The two means are
A sum need not run over all the observations. Here we sum only the second and third:
For each value of we can add in anything we want, such as the product of the two returns, or the distance of from its mean:
We think of the mean as the centre of the data. In a class survey of how many beers students claim they can drink, one answer was deleted because nobody believed it. Among the rest, the women claimed on average that they could drink beers and the men , so in this sense the men claim to drink more.
For the equity returns of the last lesson the means are
This is a big difference: about a month against about . It was hard to see in the histograms, because it is small compared with the variation of the returns.
For the returns in the table above, compute , and .
The Median
After the data have been put in order, the median is the middle value. If there is an even number of observations, the median is the average of the two middle values.
So the median of is , and the median of is .
Mean versus Median
The mean and the median are both good measures of the centre of a distribution, but the median is much less sensitive to extreme values. It depends only on which observations sit in the middle of the ordering, so making the largest value larger, or the smallest smaller, leaves it unchanged.
| data | mean | median |
|---|---|---|
Extreme values like the are the outliers of the last lesson. We used to call them funny points, but outliers sounds more scientific. Outliers are sometimes the most interesting aspect of a data set, and sometimes they are just coding errors.
In the 2004 American Sex Survey, a random-sample telephone poll of adults, women reported a median of sex partners in their lifetimes and men a median of . The means were far larger: an average of partners for women and for men. The report explains that the averages are higher because a small number of individuals, especially men, report a very large number of partners. Whether those answers are true or boasts, a handful of them moves the mean a long way and the median hardly at all.
The Mode
The mode of a data set is the value that appears most frequently, the highest point of its histogram.
People also use the word more loosely, calling any lump in a histogram a mode.
Measures of Dispersion
The mean and the median locate the centre of a set of observations, for different notions of centre. They do not measure its dispersion, or spread. Are most of the observations close to the centre, or not? What is the typical range the data fall into? The data sets and both have mean , but the second is clearly the more variable.
Often we care about the variability as well as the centre.
- Medicine: we may know the average life expectancy given a diagnosis, but what are the best and the worst cases?
- Exams: we may know the class average and our own score, but how do we really compare with the rest of the class?
- Investments: we may know the historical average annual return of a stock or a mutual fund, but is a big loss possible? Beside the average return we need a measure of risk.
Example 2.6 (Daily temperatures in two cities).
Figure 2.1 shows the daily mean temperatures in Seattle and in Chicago over 2024 and 2025, drawn on the same scale. The means of the two cities are very close, °C and °C, but the distributions are very different: the temperature in Chicago is far more variable.
Source: Open-Meteo historical weather API, ERA5 reanalysis, daily mean temperature at metres for Seattle and Chicago, 1 January 2024 to 31 December 2025, days each.
Example 2.7 (Two share prices).
Figure 2.2 shows the daily closing prices of Tesla (TSLA) and Visa (V) shares over five years. Again the means are very close, $247.34 and $248.20, but the Tesla price is clearly more variable.
Source: Yahoo Finance daily closing prices, 1 September 2020 to 29 August 2025, trading days, adjusted for share splits.
In both examples the two distributions have almost the same mean but very different spreads. Suggest a single number that could measure the spread of a set of data.
The Variance
The basic idea is to view variability in terms of the distance between each observation and the mean, . Figure 2.3 shows these distances for the two small sets of returns in the table above: overall, the distances for are bigger than those for .
We need an overall measure of how big the distances are, one number as the mean is one number. We cannot just add the distances up, because the negative distances cancel the positive ones and the sum is always zero:
Instead we square the distances, which makes them all positive, and average them.
The variance of is the average squared distance from the mean,
Example 2.9 (The heights of a rowing crew).
The eight rowers of a crew are , , , , , , and cm tall (constructed data). Their mean height is cm, and
so the variance is
The heights are in centimetres, so the variance is in square centimetres.
The Sample Variance
Definition 2.10 (Sample Variance).
The sample variance of is
We use instead of for technical reasons, to do with using a sample to estimate the variability of the population it came from, and the intuition does not change: we still think of as the average squared distance of the observations from their mean. For large the two versions are almost equal. In this lesson , with divisor , is called the variance and , with divisor , the sample variance. Statistical software usually reports the sample version.
- What is the smallest value a variance can take, and for what data does it take it?
- What are the units of the variance of a set of heights measured in metres, and of a set of monthly returns?
The Standard Deviation
It is helpful to have a measure of spread in the original units of the data. If the data have units , the variance has units , which cannot be compared with the data or with the mean. The standard deviation solves this problem.
Definition 2.11 (Standard Deviation).
The standard deviation is the square root of the variance, , and the sample standard deviation is the square root of the sample variance, . Both have the same units as the data.
So if we want a measure of variability that can be compared with the mean, we should use the standard deviation rather than the variance. For the rowers, cm.
Example 2.12 (Two small sets of returns).
For the returns in the table of the last chapter, the distances from the means are
so
The sample standard deviation of the data is bigger than that of the data. This numerically captures the fact, visible in Figure 2.3, that has more variation about its mean than .
For the equity returns of the last lesson,
| country | mean | sample standard deviation | |
|---|---|---|---|
| Canada | |||
| Japan |
and the standard deviations measure the greater spread in the Japanese returns which the histograms showed.
We now have two numerical summaries of a set of data: , which says where the data are, and , which says how spread out, how variable, they are. The mean is easy to interpret, as a sort of centre of the data. We know that the bigger is, the more variable the data are, but how do we really interpret the number? What is a big , and what is a small one?
Variability and Risk
Example 2.13 (A gift or a gamble).
Suppose someone offers a choice between a gift of $100 and the chance to flip a fair coin for $300. We can think of the outcomes in each case as the data points of a distribution. The first is a distribution with exactly one data point, $100. The second has two data points, $0 for tails and $300 for heads. For the coin flip, in dollars,
| choice | mean | standard deviation |
|---|---|---|
| gift | $100 | $0 |
| coin flip | $150 | $150 |
The gamble has the larger mean, and a standard deviation as large as its mean, which measures its risk. Which to choose depends on how much that risk matters to us.
For the temperatures of Figure 2.1,
| city | mean temperature | standard deviation |
|---|---|---|
| Seattle | °C | °C |
| Chicago | °C | °C |
and the standard deviation of the temperature in Chicago is about twice that in Seattle. For the share prices of Figure 2.2,
| share | mean price | standard deviation |
|---|---|---|
| Tesla | $247.34 | $66.78 |
| Visa | $248.20 | $47.37 |
The standard deviation of the Tesla price is about of its mean, and that of the Visa price about .
Remark.
The ratio of the standard deviation to the mean only makes sense as a measure of variability for data which cannot be negative. For data such as returns, which take both signs, the mean can be close to zero however large the spread.
The Standard Deviation and Outliers
Sometimes the standard deviation is large because of one outlier.
Example 2.14 (Attendance at tutorials).
The five tutorial groups of a course had these attendances one week (constructed data).
| group | A | B | C | D | E |
|---|---|---|---|---|---|
| attendance |
The mean is , and
If we remove the outlier, group B, the mean becomes and
One unusual group makes the standard deviation more than twice as large.
Is the standard deviation a satisfying measure of variability? What is it conveying, and what is it not conveying?
Because it squares the distances, the standard deviation can be made large by the influence of a few outliers, so it can be a pessimistic notion of variability.
Chebyshev’s Inequality
There is a guarantee which says how most observations sit relative to the standard deviation. It is called Chebyshev’s inequality: for any ,
Equivalently, at least a fraction of them lie within standard deviations of the mean. With , for example, at least of the observations are no more than two standard deviations from the mean, whatever the data.
The reason is short. Suppose that a fraction of the observations lie more than from the mean, and that there is at least one of them. Each of these observations contributes more than to the sum of the squared distances, and no term of the sum is negative, so
Dividing both sides by gives . The sample standard deviation is at least as large as , so the guarantee holds for as well.
The Standard Deviation Can Overestimate Variability
We know for sure that at least of the observations lie in the window . Very often the truth is far better than that. In Figure 2.4 almost all the days in each city, about , are within two standard deviations of the mean, and about are within one standard deviation. In such cases the width of the window gives, qualitatively, an overestimate of the variability.
The Empirical Rule
For data whose histogram is a single roughly symmetric mound, a much sharper statement is usually close to the truth.
Definition 2.15 (Empirical Rule).
For mound-shaped data,
- approximately of the data lie in the interval ;
- approximately of the data lie in the interval .
The empirical rule helps us understand and relate the two summaries back to the histogram. For the Canadian returns, and , so
The empirical rule says that roughly of the observations are between the dotted lines of Figure 2.5 and roughly between the dashed lines. Counting, of the returns, , lie within one standard deviation of the mean and , , lie within two. That looks reasonable.
The same thing can be seen from the time series plot in Figure 2.6. Five per cent of the observations outside the dashed lines would be about points; there are points outside, which is pretty close.
Remark.
Chebyshev’s inequality holds for any data at all; the empirical rule is only an approximation, and only for mound-shaped data. For the temperatures of Figure 2.4, whose histograms are not single symmetric mounds, the proportions within one and two standard deviations still happen to be close to and .
Quantiles
Quantiles tell us what fraction of the data falls in each range, which gives a more complete picture of variability.
The -quantiles of a set of data are the numbers which divide the ordered data into groups of equal size. The -quantiles are the deciles, the -quantiles the quartiles and the -quantiles the percentiles. The median is the -quantile.
We can measure variability by the distance between two quantiles, the width of the window they make. For example, the distance from the th percentile to the th:
| city | mean | standard deviation | th percentile | th percentile | – window |
|---|---|---|---|---|---|
| Seattle | °C | °C | °C | °C | °C |
| Chicago | °C | °C | °C | °C | °C |
The quantiles tell us exactly what percentage of the data fall in a range. Here of the days fall between the th and th percentiles, because of the days lie below the th percentile and above the th. So in each city we can reasonably expect the temperature to be in the window on of days, and the width of the window is a measure of the variability. The quantiles also give us a better sense of the shape of the distribution, because they show where the data are packed tightly and where they are thin.
Remark.
When the point falls between two observations, different books and programs choose the percentile slightly differently, for instance by taking one of the two neighbours or by interpolating between them. For large data sets the choice makes little difference; the percentiles here are interpolated.
How does the information we get from the standard deviation differ from the information we get from the quantiles?
Comparing Assets
We can use means and standard deviations to compare investments. For nine mutual funds and other assets, over the same months, the means and sample standard deviations of the monthly returns are these.
| asset | mean | standard deviation | |
|---|---|---|---|
| drefus | |||
| fidel | |||
| keystne | |||
| Putnminc | |||
| scudinc | |||
| windsor | |||
| eqmrkt | |||
| valmrkt | |||
| tbill |
Plotting the means against the standard deviations puts all nine on one picture, Figure 2.8. It is considered good to have a large mean return and a small standard deviation, so the best assets are towards the top left. Treasury bills have almost no variability, and keystne has the largest standard deviation without a larger mean to show for it.
The same picture compares countries, here from the monthly returns of to .
When the Mean Misleads
The Mean Is Often Good
The mean is one proxy for the centre of a distribution, and it is common to treat the centre as the typical value. In some cases this is reasonable.
Example 2.17 (Repeated experiments).
We carry out independent experiments to measure the value of a fixed, bounded quantity , such as
- the average concentration of microplastics in the London water supply;
- the plasticity of a protein;
- the fraction of students who think a hot dog is a sandwich.
Because of natural variation and measurement error, each experiment gives a possibly noisy measurement of . In such an experiment the mean of the measurements is likely to be very close to , as long as is large enough; this is the law of large numbers.
But many kinds of data we meet are not like this. The features of a data set which can throw off the mean as a measure of the typical value are
- multimodal data;
- skewed and heavy-tailed distributions;
- outliers;
- high variability.
Multimodal Data
A common intuition is that the mean is roughly where the mode is. In some cases, like the repeated experiments, this is true. But sometimes a data set is naturally multimodal.
Example 2.18 (The body mass of penguins).
The top histogram of Figure 2.10 shows the body masses of penguins of three species recorded near Palmer Station in Antarctica. There are two lumps. Many data sets like this one can be decomposed into natural subsets: here the Adélie and Chinstrap penguins, birds with mean mass g, and the Gentoo penguins, birds with mean mass g. Within each subset there is only one mode, and within the subset the mean and the mode match.
Source: Palmer Station penguin data, Gorman, Williams and Fraser (2014), in the palmerpenguins data set; the penguins with body mass and bill measurements recorded.
In a multimodal data set the mean of the whole data set lies between the means of the different modes, and then it is not representative of a typical observation. The mean mass of all penguins is g, which is heavier than of the Adélie and Chinstrap penguins and lighter than of the Gentoos: a typical penguin of neither kind.
The same happens when we split the penguins by sex, in Figure 2.11. The mean for the entire data set is on the large end for a female, heavier than of the females, and on the small end for a male, lighter than of the males.
- Should the median of a multimodal data set be influenced by the multiple modes?
- Should its quantiles?
- Should its standard deviation?
All three are influenced, in the sense that the median, quantiles and standard deviation of the aggregate data do not reflect what is going on within the separate modes.
Why It Matters
Many times the mean and other summary statistics are used to make decisions. When the decisions are based on statistics of all the data, instead of mode by mode, they might not be the right decisions for everyone.
Example 2.19 (The duration of symptoms).
A medical researcher at a hospital records how long patients experience the symptoms of a new disease (constructed data). The average duration is days, and the histogram at the top of Figure 2.12 does not look obviously multimodal. But suppose the researcher analyses separately the patients without hypertension and the with it. The average duration is days for the patients without hypertension and days for those with it. Advice built on days would ask most patients without hypertension to wait too long, and tell most patients with hypertension to expect their symptoms to end too soon.
Cheng et al. study the time from exposure to the onset of COVID-19 symptoms. Could such data be multimodal? Suppose recommendations for how long to isolate after close contact are based on the distribution of this time. In what sense is that problematic, and what trade-offs have to be made?
Misleading Means in the Media
The American Medical Association reports that the average American consumes about milligrams of sodium a day, against a recommended limit of milligrams.
Is the figure of mg representative of most people? Could the data be multimodal? Is there a lot of variability?
A closer look comes from a national study which estimated sodium intake from -hour urine samples. It found a mean of mg a day for men and mg for women, and that on a given day of adults, of men and of women, consumed at least the recommended mg. So
- the data are multimodal: men and women consume quite different amounts on average;
- the variability is limited, in the sense that three adults in four are above the recommended amount.
The conclusion that Americans eat more salt than the medical community suggests they should is still valid, but a single figure of mg describes neither men nor women well.
Source: American Medical Association, What doctors wish patients knew about sodium consumption; Cogswell et al., Estimated 24-hour urinary sodium and potassium excretion in US adults, JAMA (2018).
Skew
Even when a distribution has only one mode, it can be skewed: its histogram stretches out to the left or to the right. There are several quantitative measures of skewness, and only the concept matters here. The stretched-out part looks like a tail, so a skewed distribution is sometimes also said to be heavy-tailed.
Right Skew
Types of data which tend to be skewed to the right are
- incomes, GDP, the number of awards won, and views or clicks online, where the rich get richer;
- waiting times, such as the time between earthquakes or volcanic eruptions;
- the sizes of some natural objects, such as lakes, rocks and mineral deposits.
If a distribution is skewed to the right, then typically the median and the mode are smaller than the mean.
In 2000 the countries with a recorded GDP had a mean GDP of $164.7 billion and a median of only $7.9 billion. A few enormous economies pull the mean far to the right of where almost every country lies, as Figure 2.13 shows.
Source: World Bank, GDP (current US$), indicator NY.GDP.MKTP.CD, individual countries only.
Left Skew
Types of data which tend to be skewed to the left are the age at death and exam scores. If a distribution is skewed to the left, then typically the median and the mode are larger than the mean.
The scores of a class on an exam (constructed data) pile up between and , with a tail of weaker scripts down to . The mean is and the median is .
Measuring Skew
The gap between the mean and the median is one quantitative measure of skew. It is positive for the GDP data, which are skewed to the right, and negative for the exam scores, which are skewed to the left.
Outliers
Outliers, abnormally large or small values, can move the mean away from the median or the mode. Outliers and skew are related, since outliers do skew the distribution; the distinction is usually that we think of outliers as anomalies, whereas skew can be a natural property of the data.
Example 2.22 (Time on social media).
A class survey asked “How many minutes per day do you spend on social media?” (constructed data). Twenty students answered between and minutes, and one replied hours, that is minutes. This is an outlier.
| statistic | with the outlier | without the outlier |
|---|---|---|
| mean | min | min |
| standard deviation | min | min |
| median | min | min |
The standard deviations use divisor . The one answer moves the mean by nearly minutes and multiplies the standard deviation by almost four, and it does not move the median at all.
The tutorial attendances earlier showed the same effect of an outlier on the standard deviation.
High Variability
If the variability of a data set is high, then neither the mean nor the median is representative of a typical observation.
Example 2.23 (Hours of study).
A survey asked students “How many hours per week do you spend studying?” (constructed data). The mean, hours, and the median, hours, are pretty close. But the answers run from to hours with a standard deviation of hours, so neither nor can be taken as the answer of a typical student.
Gambling gives another situation where the mean is not necessarily representative. When we flip a fair coin for $300, the mean outcome is $150, but the outcome is either $0 or $300, and neither is anything like the mean.
A Robust Measure of Variability
If the standard deviation is so easily inflated by outliers and heavy tails, what should we use instead? Quantile widths are much more robust to outliers. In the social media survey, the window from the th to the th percentile is minutes wide without the outlier and minutes wide with it, while the standard deviation jumps from to minutes.
Relating Two Variables
The mean and the standard deviation summarise a set of numbers which are measurements of just one thing, one variable. A different question is how one thing relates to another. Often each observation contains measurements of several variables:
- medical records: age, weight, blood pressure;
- property sales: price, floor area;
- the penguins: flipper length, body mass, bill length.
We often want to know whether two variables are positively or negatively associated. When we examine two variables at a time, the scatter plot is the main graphical tool, and covariance and correlation are the main numerical summaries.
Scatter Plots
Example 2.24 (Beer and weight).
In the class survey of how many beers students claim they can drink, each student also gave their weight in pounds. The first ten answers are these.
| student | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| beers | ||||||||||
| weight |
Now we think of each pair of numbers as an observation. Each pair corresponds to a person, with two numbers associated with them, the number of beers and the weight, and each pair corresponds to a point on the plot. Is the number of beers you can drink related to your weight?
In general the data look like pairs, and the th observation is a pair of numbers . The plot enables us to see the relationship between and . As another example, we could plot the monthly returns on the windsor mutual fund against the returns on the market as a whole, valmrkt, with each point a month, to ask whether the returns on a fund are related to the market’s.
In both examples there does seem to be a relationship. Even more, the relationship looks linear, in that we could draw a line through the plot to capture the pattern. Covariance and correlation summarise how strong a linear relationship there is between two variables.
Covariance and Correlation
Definition 2.25 (Sample Covariance and Sample Correlation).
The sample covariance between and is
The sample correlation between and is the covariance divided by the two standard deviations,
The correlation is always a number between and :
- The closer is to , the stronger the linear relationship with a positive slope: when one variable goes up, the other tends to go up.
- The closer is to , the stronger the linear relationship with a negative slope: when one goes up, the other tends to go down.
The correlation between windsor and valmrkt is , and over the whole beer survey the correlation between the number of beers and weight is (for the ten students in the table alone it is ). The larger correlation between windsor and valmrkt indicates that their linear relationship is the stronger one. Figure 2.18 shows some more examples.
The last plot is a warning. The correlation only measures linear relationships: here its value is small, but there is a strong nonlinear relationship between and .
Example 2.26 (The country data).
Which countries’ markets go up and down together? With many countries that would be a lot of scatter plots. Figure 2.19 shows one of them, the USA against Canada, with correlation .
To summarise all of them we compute every pairwise correlation.
| Aus | Bel | Can | Fin | Fra | Ger | HK | Ita | Jap | USA | |
|---|---|---|---|---|---|---|---|---|---|---|
| Belgium | ||||||||||
| Canada | ||||||||||
| Finland | ||||||||||
| France | ||||||||||
| Germany | ||||||||||
| Hong Kong | ||||||||||
| Italy | ||||||||||
| Japan | ||||||||||
| USA | ||||||||||
| Singapore |
The upper half of the table is left blank because the correlation between two countries does not depend on the order in which we take them, so it would repeat the lower half, and the diagonal would only record that each country is perfectly correlated with itself. The most closely linked markets are neighbours: Belgium and France, France and Germany, Canada and the USA, Hong Kong and Singapore.
Understanding the Formulae
To get a feeling for how these formulae capture a relationship, we go back to the four years of returns on two assets and compute their covariance and correlation. First the covariance, which is the necessary ingredient:
Each of the four points makes a contribution to the sum. Figure 2.20 shows which point does what.
- A point in region I has both and bigger than their means, so it makes a positive contribution to the covariance.
- A point in region II has both and less than their means, so it also makes a positive contribution.
- In regions III and IV one of and is less than its mean and the other is greater, so the contribution is negative.
The further out the point is, the bigger its contribution. A scatter plot with most of its points in regions I and II, and just a few relatively small contributions from regions III and IV, has a positive covariance. So
- a positive covariance means that when one variable is above its average the other tends to be above its average as well: they move up and down together;
- a negative covariance means that when one is up the other tends to be down: they move in opposite directions;
- a small covariance means that their movements are almost linearly unrelated.
We finish the example with the correlation, using and from before:
The division by the standard deviations standardises the covariance, so that the correlation is always between and . The correlation has the same sign as the covariance, since standard deviations are always positive, so its sign carries the same information: a positive sign means a positive relationship and a negative sign a negative one. The correlation is more informative, though, because it is unit-less and always between and by construction, which makes it the better measure of the strength of the relationship.
The Slope of the Best-Fit Line
Should the body mass of a penguin be positively or negatively associated with its bill length? Figure 2.21 suggests a positive association: heavier penguins tend to have longer bills. How can we quantify it? One idea is the slope of the best-fit line through the scatter plot, but the slope has two problems.
The slope is sensitive to units. With body mass in grams the slope of the best-fit line is mm per gram. If we measure the same penguins in ounces, the points and the line look exactly the same, but the slope becomes mm per ounce. An ounce is grams, so the same rise in bill length now happens over a run times smaller in number, and the slope is times larger.
The slope is also sensitive to variability. Some variables vary much less than others, and then the slope can never be large. Bill length varies only from to mm, while body mass varies from to g.
- What is the slope of the line through the points and ?
- Explain why, if a variable varies in the range to and a variable varies in the range to , the slope of the best-fit line of on will never get close to .
When we meet a number we always want to put it in context. What can we compare it with? Can we transform it so that it is easier to compare? In the last lesson we transformed counts into percentages to make them easier to compare, and instead of the dollars lost to fraud we looked at the percentage of the budget lost to fraud. Here we set up a measure of association which is easy to compare across different kinds of data, by rescaling the data so that they are unitless and have the same variability.
Standardising
Definition 2.27 (Standardised Data).
To standardise the data , subtract the mean from every observation and divide by the standard deviation . The standardised data are , where
Explain why standardised data always have mean and standard deviation , and why they are unitless.
So standardising equalises the variability: if we want to find an association between two data sets and standardise both first, both have the same standard deviation.
The Correlation Coefficient
Our data contain pairs , and we want to measure the association between and . The correlation coefficient is the slope of the best-fit line through the standardised and data, and it can be computed as the average product of the standardised values:
This is the same number as the sample correlation . The sum is divided by . Using divisor throughout, in the covariance and in both standard deviations, multiplies the top by and the bottom by as well, so the factors cancel.
For the penguins, with the body mass and the bill length, the association is positive but not perfect: .
Remark.
The quantity , the covariance with divisor , is sometimes itself called the correlation. It is the correlation coefficient without the rescaling by the standard deviations.
What Correlation Can Tell Us
Covariance, correlation and the correlation coefficient are summary statistics of two variables which quantify the association between them.
- If there is a strong association between two variables, knowing one helps a lot in predicting the other. The correlation between body mass and bill length, for instance, lets us estimate the average bill length of penguins of a given weight.
- When there is a weak association, information about one variable does not help much in guessing the other.
The correlation coefficient has three useful properties.
- It is unitless.
- Changing the units of or of , as from grams to ounces, does not change it.
- It does not change if we interchange and : like the covariance, it is symmetric in the two variables.
Correlation Is Not Causation
If and are correlated, can we infer that causes , or that causes ? No. Many variables are correlated without any causal relationship between them. For the years to the divorce rate in the US state of Maine and the consumption of margarine per person in the US have a correlation coefficient of . Both fell over the decade, for quite unrelated reasons.
Source: Tyler Vigen, Spurious Correlations
Robustness
Like the mean and the standard deviation, the correlation can be greatly affected by outliers.
Example 2.28 (GDP in 1960 and 2000).
For the countries with a GDP recorded in both and , the correlation between the two is . But the data are dominated by a few very large economies: of the countries, of them, had a GDP below the mean. For those countries alone the correlation is only .
Source: World Bank, GDP (current US$), individual countries with values for both years.
Associations Not Captured by Correlation
Variables can be associated without being linearly associated. In the last plot of Figure 2.18, is a quadratic function of , so knowing tells us exactly, yet the correlation coefficient is only .
Simpson’s Paradox
Sometimes, if a data set has several groups or modes, the slope of the best-fit line for the whole data set differs from the slope for each group, even in sign. This phenomenon is called Simpson’s paradox.
Example 2.29 (The bills of penguins).
The length and depth of the penguins’ bills appear negatively associated when we look at all three species together: the correlation is . But when we look at each species separately, the two are clearly positively associated, with correlations for the Adélie, for the Chinstrap and for the Gentoo penguins. The Gentoos have long, shallow bills and the Adélies short, deep ones, and that difference between the species produces the downward slope of the combined data.
Linearly Related Variables
We have studied data sets which display some kind of relationship with each other, such as the returns on a mutual fund and on the market. Sometimes there is an exact linear relationship between two variables,
Can we then say something about the mean of if all we know is the mean of , and something about the standard deviation of if all we know is the standard deviation of ?
Example 2.30 (Celsius and Fahrenheit).
These temperatures are recorded in degrees Celsius and in degrees Fahrenheit, which are related by .
| Celsius | ||||||||
|---|---|---|---|---|---|---|---|---|
| Fahrenheit |
If we plot the Fahrenheit values against the Celsius values, every point lies on one straight line, and the correlation is exactly .
Definition 2.31 (Linear Function).
The variable is a linear function of the variable if
where the constants and are fixed numbers, the intercept and the slope, while and vary.
Example 2.32 (A film star's pay).
A film star has a deal which pays a fee of $10 million per film plus of the film’s gross takings. In millions of dollars the star’s income from a film is
a linear function of the gross, with intercept and slope .
Mean and Standard Deviation of a Linear Function
Suppose the data are a linear function of the data . To see how the mean and standard deviation of are related to those of , take eight Celsius temperatures, multiply them by , and then add to obtain Fahrenheit.
| mean | sample standard deviation | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Celsius | ||||||||||
| Fahrenheit |
- When we multiply by we increase both the mean and the standard deviation proportionally: and .
- When we add a constant, here, we simply increase the mean by the value of the constant and leave the dispersion unaffected.
In general, if for every , then
We see this by averaging, , which gives . Squaring, , and summing and dividing by gives .
- The film star makes films, and the mean and standard deviation of the gross takings of the films are and million dollars. What are the mean and the standard deviation of the star’s income per film?
- The data have mean and standard deviation . What are the mean, standard deviation and variance of , of and of ?
Linear Combinations
We may want a variable to be related to several others instead of just one. Suppose the film star also receives of all sales of the soundtrack album released with the film. In millions of dollars, the star’s income is then related to the film’s gross and to the album’s sales by
Definition 2.33 (Linear Combination).
A variable is a linear combination of the variables if
for constants . The constant is the coefficient of .
Portfolios
The most important example of a linear combination is a portfolio.
Example 2.34 (Splitting an investment).
Suppose we have $100 to invest in two assets. Let be the return on asset : if and we put all our money into asset , we have $110 at the end of the period. Let be the return on asset : if and we put all our money into asset , we have $115. Suppose instead we put half the money into each. At the end of the period we have, in dollars,
so the return on the split investment is .
To generalise, let be the fraction of our wealth invested in asset , the fraction invested in asset , and our wealth. The ‘s are called the portfolio weights, and . At the end of the period we have
so the return on the portfolio is
The return on the portfolio is a linear combination of the asset returns, whose coefficients are the portfolio weights. In the same way, if we have assets, the return on the th is , and we put a fraction of our wealth into asset , then the portfolio is determined by its weights and its return is
The portfolio weights always add up to one: if we invest of our wealth in asset and have only two assets, we must invest in asset .
- Can the portfolio weights add up to one with some of them negative? What does it mean to invest of our wealth in asset and in asset ?
- What is the equally weighted portfolio of assets?
- What is a value-weighted portfolio?
Example 2.35 (The country data again).
Suppose we had put half our money into the USA and half into Hong Kong. For each month the portfolio return is . The first five months are these.
| month | Hong Kong | USA | portfolio |
|---|---|---|---|
| February 1988 | |||
| March 1988 | |||
| April 1988 | |||
| May 1988 | |||
| June 1988 |
How do the returns on this portfolio compare with those of Hong Kong and the USA? In Figure 2.26 the mean of the portfolio is right in between the means of the USA and Hong Kong. Its standard deviation, however, is closer to the USA’s than halfway.
A portfolio can also use three countries. Suppose we go short on Canada, that is we borrow Canadian shares worth half our wealth and sell them, and invest in the other two:
The weights add up to . This portfolio has a mean monthly return of , above the USA’s and close to Hong Kong’s , with a standard deviation of , far below Hong Kong’s . Forming portfolios is clearly an interesting thing to do.
Why would we form portfolios? Perhaps a portfolio has a nicer mean and variance, a nicer average return and a nicer risk, than the assets it is made of. Some basic formulae relate the mean and standard deviation of a linear combination to the means, variances and covariances of its inputs, and applying them to portfolios shows how the mean and variance of a portfolio depend on the assets in it. These formulae are the basic part of the tool-kit of anyone working in finance.
Mean and Variance of a Linear Combination
First we consider the case of only two inputs. If for every observation , then
We see this as for a single input. Averaging gives the formula for , and then
Squaring,
and summing over and dividing by gives the formula for . The covariance term is why the variance of a combination differs from the same combination of the variances.
Going back to the film star, suppose the average sales of the album are $5 million with a standard deviation of $1 million, and that the correlation between a film’s gross and its album sales is .
- What are the mean and the standard deviation of the star’s income?
- How would the answer change if the correlation were ?
Example 2.36 (Checking the formulae on the country data).
For the portfolio , the mean returns on the USA and Hong Kong are and . Knowing the portfolio returns, the sample mean of the portfolio return is , and the formula agrees:
The sample variances and covariances of the three series are these.
| Hong Kong | USA | portfolio | |
|---|---|---|---|
| Hong Kong | |||
| USA | |||
| portfolio |
The diagonal elements are variances and the off-diagonal elements are covariances; a table like this is a variance–covariance matrix. As before we can check the formula for the variance:
which is the variance of the portfolio up to rounding.
Let us do it one more time, for the portfolio , whose sample variance is :
Example 2.37 (The effect of the covariance).
Each plot of Figure 2.28 shows constructed pairs , and in each case .
- In the first plot , and , so . The variance of is much smaller than those of the ‘s, because the covariance is large and negative: whenever is above its mean tends to be below its mean by about as much, and the average hardly moves.
- In the second, , and , so . The variance of is not much smaller than those of the ‘s, because the two move up and down together and averaging cancels almost nothing.
- In the third, , and , so . The covariance is small, and the variance of is noticeably smaller than those of the ‘s: averaging two variables which are nearly unrelated reduces the variability.
With inputs, if , the same argument gives and
where the second sum runs over all pairs of inputs. For three inputs this is
Example 2.38 (A portfolio of three funds).
Take the portfolio . The sample variances and covariances of the four series are these.
| portfolio | fidel | eqmrkt | windsor | |
|---|---|---|---|---|
| portfolio | ||||
| fidel | ||||
| eqmrkt | ||||
| windsor |
The formula for three inputs gives
which is exactly the variance of the portfolio.
Exercises
The first five monthly returns of Hong Kong and the USA were and .
- Compute by hand the mean and the sample variance of each series, and their sample covariance.
- Use the formulae for a linear combination to find the mean and the sample variance of the portfolio over these five months.
- Check your answers against the portfolio returns .
Of the monthly Japanese returns, lie more than one standard deviation from the mean, lie more than two standard deviations from it, and one lies more than three.
- What proportions lie within one, two and three standard deviations of the mean?
- Compare these proportions with what Chebyshev’s inequality guarantees and with what the empirical rule predicts.
In the American Sex Survey, men reported a median of lifetime partners and a mean of , and women a median of and a mean of .
- What do these figures suggest about the shape of each distribution?
- Which of the two summaries better describes a typical respondent, and why?
- A newspaper headline reads “The average man has had 20 partners”. What is misleading about it?
Seattle’s daily mean temperatures over 2024 and 2025 have mean °C and standard deviation °C, with th and th percentiles °C and °C. Using , find the mean, the standard deviation and the – percentile window in degrees Fahrenheit, and explain why the correlation between the Seattle and Chicago temperatures would not change if both were converted to Fahrenheit.
Over the months, the Canadian and USA monthly returns have means and , standard deviations and , and correlation . Find the mean and the standard deviation of the portfolio , and compare them with those of the two countries.
The five pairs are , , , and .
- Compute by hand the sample covariance and the correlation between and .
- Find the sample covariance and the correlation between and .
Show that if for every , with , then the correlation between and equals the correlation between and when , and is its negative when .
Chicago’s daily mean temperatures over 2024 and 2025 have mean °C and standard deviation °C, and of the days lie within three standard deviations of the mean.
- What proportion does Chebyshev’s inequality guarantee within three standard deviations?
- Find the interval of temperatures within three standard deviations of the mean.
- The coldest day was °C. Was it inside the interval?
Check Yourself
Fresh questions on the whole lesson — none of them is worked out above. Do each on paper first; the box only tells you whether you got there.
Answers are checked in your browser, as often as you like. Nothing is sent anywhere and
nothing is kept but your own work. A formula may be written with the symbols themselves or
with ~ & | -> <-> ^, and \and, \or, \to expand as you type.
What is the mean of ?
What is the median of ?
What is the sample variance of ?
Masses are recorded in kilograms. In what units is their variance?
If is added to every observation, what happens to the mean and the standard deviation?
The data have standard deviation . What is the standard deviation of ?
By Chebyshev’s inequality, at most what fraction of any data set lies more than three standard deviations from the mean?
For mound-shaped data, about what percentage of the observations lie within two standard deviations of the mean?
What is the correlation between and for the pairs , , ?
A distribution is strongly skewed to the right. Which is usually true?
Two assets have mean returns and . What is the mean return of the portfolio with weights and ?
The variables and have sample variances and and sample covariance . What is the sample variance of ?
The correlation between body mass in grams and bill length in millimetres is . What is the correlation between body mass in kilograms and bill length in centimetres?
What fraction of a data set lies between its th and th percentiles?