Lesson 2
Summarising Data
The mean, median and mode; variance, standard deviation, Chebyshev's inequality, the empirical rule and quantiles; when the mean misleads; covariance and correlation; and the mean and variance of linear combinations, with portfolios as the main example.
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 what makes the variance of a combination more than the 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?