Shifting and rescaling a data set
Every value in a data set has the same number added to it, or is multiplied by the same number, as when the units change. Do the mean and the standard deviation have to be worked out again from scratch?
Where you are 13 in Center and spread
When you reach for it
A data set often has to be changed as a whole. A shop adds the same delivery fee to every order. A thermometer that reads 1.5^\circ\text{C} too high has 1.5 taken off every reading. Times in minutes are reported in hours, lengths in centimeters in meters, a fridge log kept in Celsius is reported in Fahrenheit. In each case one rule is applied to every value: add a constant, multiply by a constant, or both.
The summaries of the new data follow from the old ones without touching a single value. That matters when there are hundreds of values, or when only the summary was published. All the data in this lesson are made up.
The procedure
Write the old values as x_1, x_2, \ldots, x_n, with mean \bar{x} and standard deviation \sigma_x.
Adding a constant
Add the same number c to every value: y_i = x_i + c. Every one of the n values gains c, so the total gains nc, and dividing by n,
Adding c does not change the order of the values, so the value in each position of the sorted list is the old one plus c. The minimum, the maximum, the median and both quartiles therefore all move by c, and so does any percentile, found the way a percentile is read from a sorted list.
Spread does not move. The range is (\text{max} + c) - (\text{min} + c), and the c cancels; the interquartile range Q_3 - Q_1 loses its c in the same way. For the standard deviation, look at the deviations from the mean:
Every deviation is exactly what it was, so their squares, the variance and its square root are all unchanged.
The picture says the same thing. Every dot of a dot plot moves the same distance, so the whole plot slides along the axis with every gap kept (Figure 1). The shape, symmetric or skewed, one peak or two, is untouched, and a Relative frequency histograms slides in the same way with its bar heights kept.
Multiplying by a positive constant
Multiply every value by the same k > 0: y_i = kx_i. Taking out the common factor,
A positive multiplier keeps the order, so the minimum, the maximum, the median, the quartiles and every percentile are all multiplied by k. This time spread changes too: the range becomes k(\text{max}) - k(\text{min}) = k \times \text{range}, and the interquartile range becomes k times as long. The deviations are all scaled by k:
Squaring multiplies each squared deviation by k^2, so the variance is multiplied by k^2, and the standard deviation, its square root, by \displaystyle \sqrt{k^2} = k.
On a plot, every distance from 0 is multiplied by k, so the data are stretched (for k > 1) or squeezed (for k < 1), and also moved, since the center is multiplied too. The form survives: a plot skewed to the right is still skewed to the right, and a peak stays a peak.
Both at once
Many changes multiply and then add: y = a + bx with b > 0. Apply the two results one after the other.
The median, quartiles, minimum and maximum go through the whole rule just as the mean does; the range and IQR are multiplied by b just as the standard deviation is. Each measure of spread feels only the multiplier, because the constant cancels whenever one value is taken from another. The order of the steps matters: adding a fee of f and then raising by 20\% is y = 1.2(x + f) = 1.2x + 1.2f, not 1.2x + f. Writing the rule as a + bx first settles it. One more consequence: a value flagged as an outlier in a Box plots that show outliers is still flagged afterwards, since the fences Q_1 - 1.5 \times \text{IQR} and Q_3 + 1.5 \times \text{IQR} go through the same rule as the data.
Worked examples
A delivery fee
Ashlyn’s online shop logged eight orders, in dollars: 12, 15, 15, 18, 20, 24, 30, 42. Their mean is 22, median 19, quartiles Q_1 = 15 and Q_3 = 27, and standard deviation about 9.26. A flat delivery fee of 5 dollars is then added to every order. Give the new summaries.
SolutionAdding 5 to every value moves every measure of center and position by 5 and leaves every measure of spread alone.
| before | with the fee | |
|---|---|---|
| mean | 22 | 27 |
| median | 19 | 24 |
| Q_1, Q_3 | 15, 27 | 20, 32 |
| min, max | 12, 42 | 17, 47 |
| range | 30 | 30 |
| IQR | 12 | 12 |
| standard deviation | 9.26 | 9.26 |
Check the mean directly: the new total is 176 + 8 \times 5 = 216, and \displaystyle \frac{216}{8} = 27. Figure 1 shows both dot plots: the same cluster, 5 dollars further right.
Minutes to hours
The delivery times of the same shop’s orders have mean 96 minutes, median 90 minutes, quartiles 72 and 108 minutes, standard deviation 30 minutes and variance 900 square minutes. Report them all in hours.
SolutionOne hour is 60 minutes, so each time in hours is the time in minutes multiplied by \displaystyle \frac{1}{60}, a conversion factor equal to one. This is a rescale with \displaystyle k = \frac{1}{60}, and nothing is added.
The mean is \displaystyle \frac{96}{60} = 1.6 hours and the median \displaystyle \frac{90}{60} = 1.5 hours. The quartiles are \displaystyle \frac{72}{60} = 1.2 and \displaystyle \frac{108}{60} = 1.8 hours, so the IQR is 0.6 hours, which is also \displaystyle \frac{36}{60}. The standard deviation is \displaystyle \frac{30}{60} = 0.5 hours.
The variance is multiplied by \displaystyle k^2 = \frac{1}{3600}: \displaystyle \frac{900}{3600} = 0.25 square hours. As a check, 0.5^2 = 0.25, so the new standard deviation and the new variance agree.
A fee, then a percent increase
Ashlyn’s shop now adds the 5 dollar fee and then raises each total by 20\%. Using the summaries from Example 1, find the new mean, median, standard deviation and IQR. Would raising first and then adding the fee give the same totals?
SolutionRaising by 20\% multiplies by 1.2. The fee comes first, so each new total is
So a = 6 and b = 1.2. The center goes through the whole rule: \bar{y} = 1.2 \times 22 + 6 = 32.4 dollars, median 1.2 \times 19 + 6 = 28.8 dollars. The spread feels only the 1.2: standard deviation 1.2 \times 9.26 \approx 11.11 dollars, IQR 1.2 \times 12 = 14.4 dollars.
Raising first gives y = 1.2x + 5, which is 1 dollar less on every order, because then the fee is not raised. Its mean would be 31.4 dollars, its standard deviation the same 11.11.
Figure 2 shows the three stages: the fee slides the box plot, and the increase moves it again and stretches every part to 1.2 times its width.
A fridge log in Fahrenheit
Over ten days a café logged its fridge each morning, in degrees Celsius: 2, 3, 3, 3, 4, 4, 4, 5, 5, 7. The mean is 4, the median 4, the quartiles 3 and 5, and the standard deviation about 1.34^\circ\text{C}. The owner, Basilio, has to report the log in Fahrenheit, using F = 1.8C + 32 from Converting between Celsius and Fahrenheit.
SolutionThe conversion is y = a + bx with b = 1.8 and a = 32. Center and position go through the whole rule:
The spread is multiplied by 1.8 only: the IQR is 1.8 \times 2 = 3.6 Fahrenheit degrees, the range 1.8 \times 5 = 9, and the standard deviation 1.8 \times 1.34 \approx 2.41. The 32 has no place in a spread, which measures distances between temperatures, just as a change of temperature converts by the factor 1.8 alone. The variance, 1.8 square Celsius degrees, becomes 1.8^2 \times 1.8 = 5.832 square Fahrenheit degrees.
Back from Fahrenheit
A second fridge’s log arrives already in Fahrenheit: mean 37.4^\circ\text{F}, median 36.5^\circ\text{F}, standard deviation 2.7 Fahrenheit degrees, IQR 4.5 Fahrenheit degrees. Find each in Celsius and compare the two fridges.
SolutionEvery Fahrenheit summary came from the Celsius one by y = 1.8x + 32, so undo it: take away 32, then divide by 1.8. For the mean, 37.4 = 1.8\bar{x} + 32 gives \displaystyle \bar{x} = \frac{37.4 - 32}{1.8} = \frac{5.4}{1.8} = 3^\circ\text{C}, and for the median \displaystyle \frac{36.5 - 32}{1.8} = \frac{4.5}{1.8} = 2.5^\circ\text{C}.
A spread only ever saw the 1.8, so only divide: standard deviation \displaystyle \frac{2.7}{1.8} = 1.5 Celsius degrees, IQR \displaystyle \frac{4.5}{1.8} = 2.5 Celsius degrees.
The second fridge runs about 1^\circ\text{C} colder on average than the café’s (3 against 4), and its readings vary a little more (1.5 against about 1.34).
Finding the rule
Ashlyn’s shop later dropped the pricing of Example 3 and instead changed the original totals of Example 1 by one rule y = a + bx, with b > 0, for every order. Before the change, the totals had mean 22, median 19, IQR 12 and standard deviation 9.26 dollars; after it, the median was 26.85 and the IQR 13.80 dollars. Find the rule, the new mean and the new standard deviation, and say what the rule did in words.
SolutionStart with a spread, since it sees only b: 13.8 = 12b, so b = 1.15. Then a measure of center gives a: 26.85 = 1.15 \times 19 + a = 21.85 + a, so a = 5. The rule is y = 1.15x + 5.
New mean 1.15 \times 22 + 5 = 30.3 dollars; new standard deviation 1.15 \times 9.26 \approx 10.65 dollars.
In words: a 15\% increase, then a flat 5 dollar fee. The other order, fee first, would need 1.15(x + f) = 1.15x + 5, so \displaystyle f = \frac{5}{1.15} \approx 4.35, not a whole number of cents. Both readings give the same totals, but a shop sets its fee in whole cents, so the likely story is a 15\% increase followed by a 5 dollar fee.
Boundaries
The same rule for every value. A fee added to some orders and not others, or a discount that depends on the size of the order, is not a shift or a rescale, and the summaries must be worked out again from the data.
Only adding and multiplying. Squaring every value, or taking square roots, does not carry the mean along: 1 and 3 have mean 2, but 1^2 and 3^2 have mean 5, not 2^2 = 4.
A positive multiplier. For b < 0 the center still becomes a + b\bar{x}, but every spread is multiplied by |b|, the order reverses (the maximum becomes the minimum, Q_1 and Q_3 swap) and the shape flips, so a right skew becomes a left skew.
Either standard deviation. Dividing by n or by n - 1, the deviations scale the same way, so every rule here holds for both.
Rounding. A rounded summary gives a rounded result: 1.8 \times 1.34 is 2.412, while the exact standard deviation in Example 4 gives 2.41495\ldots. Report no more places than the input had.
Where this goes next
The most used shift and scale in statistics is standardizing: subtract the mean, then divide by the standard deviation. By this lesson’s rules the result has mean 0 and standard deviation 1, whatever the data were. The same two moves act on graphs, where adding to every output is a Shifting a graph up, down, left and right and multiplying it is a vertical stretch. Standard deviations are computed by hand in Computing a standard deviation, sample and population and read in context in Interpreting a standard deviation.
Exercises
Adding a constant
- The data 4, 7, 7, 9, 13 have 6 added to every value. Find the new mean, median and range.
- A data set has mean 61, median 58, standard deviation 7.5, IQR 10, minimum 40 and maximum 90. Every value has 15 taken away. Give all six new summaries.
- A fridge probe reads 1.5^\circ\text{C} too high. Its log has mean 5.2, median 5.0, Q_1 = 4.6, Q_3 = 5.9 and standard deviation 0.8, all in ^\circ\text{C}. Give the corrected summaries, and the corrected IQR.
- Find the mean and variance of 2, 4, 4, 6. Without computing again, give the mean and variance of 102, 104, 104, 106, then check by computing.
Multiplying by a constant
- The data 3, 5, 6, 10 have mean 6 and variance 6.5. Every value is multiplied by 4. Find the new mean, variance and range.
- Bjarke measured fence posts: mean 182 cm, median 180 cm, standard deviation 6 cm, IQR 8 cm, variance 36 square cm. Give all five in meters.
- The times to pack an order have mean 4.5 minutes, median 4 minutes, standard deviation 1.2 minutes and variance 1.44 square minutes. Give all four in seconds.
- A data set has standard deviation 2.5. Every value is tripled. Find the new standard deviation and the new variance.
Shifting and rescaling
- A fridge log has mean 3.5^\circ\text{C}, median 3.2^\circ\text{C}, standard deviation 0.5 and IQR 1.0 Celsius degrees. Report all four in Fahrenheit, using F = 1.8C + 32.
- Aveline’s orders have mean 30, median 26, standard deviation 6, minimum 10 and maximum 70, in dollars. Each has a 3 dollar fee added and is then raised by 10\%. Find the new mean, median, standard deviation, minimum, maximum and range.
- In exercise 10, the shop raises by 10\% first and then adds the 3 dollar fee. Find the new mean and median. How do the two orders of steps compare on each order?
- A data set has mean 12, standard deviation 3, Q_1 = 9 and Q_3 = 14. Each value x becomes 2x - 5. Find the new mean, standard deviation, quartiles and IQR.
- The data 1, 2, 4, 5 have mean 3 and variance 2.5. Each value becomes 3x + 2. Predict the new mean and variance, then check by listing the new values.
Working backwards
- A fridge log reported in Fahrenheit has mean 39.2^\circ\text{F}, median 38.3^\circ\text{F} and standard deviation 1.08 Fahrenheit degrees. Find all three in Celsius.
- A data set is changed by y = a + bx with b > 0. Its mean goes from 20 to 45 and its standard deviation from 4 to 10. Find a and b.
- Every order had a flat fee added and was then raised by a percent. The median went from 19 to 25.30 dollars and the IQR from 12 to 13.20 dollars. Find the percent and the fee, and the new mean if the old mean was 22 dollars.
Reasoning
- Adding 10 to every value makes every value bigger. Explain, using deviations from the mean, why the standard deviation still does not change.
- Show that multiplying every value by k > 0 multiplies the variance by k^2, and explain why the standard deviation is multiplied by k and not by k^2.
Answers
- Mean 14, median 13, range 9. The old mean is \displaystyle \frac{40}{5} = 8 and the old median 7, each plus 6; the range stays 13 - 4 = 9.
- Mean 46, median 43, minimum 25, maximum 75; standard deviation 7.5 and IQR 10 unchanged. Subtracting 15 moves center and position only.
- Mean 3.7, median 3.5, Q_1 = 3.1, Q_3 = 4.4, standard deviation 0.8, all in ^\circ\text{C}. The IQR is 5.9 - 4.6 = 1.3 before and 4.4 - 3.1 = 1.3 after.
- Mean 4, variance \displaystyle \frac{8}{4} = 2 (deviations -2, 0, 0, 2). Adding 100 gives mean 104 and variance still 2: the deviations from 104 are again -2, 0, 0, 2.
- Mean 4 \times 6 = 24, variance 4^2 \times 6.5 = 104, range 4 \times 7 = 28. The new data are 12, 20, 24, 40.
- Mean 1.82 m, median 1.8 m, standard deviation 0.06 m, IQR 0.08 m, variance \displaystyle \frac{36}{10000} = 0.0036 square meters. Here \displaystyle k = \frac{1}{100} and \displaystyle k^2 = \frac{1}{10000}.
- Mean 270 s, median 240 s, standard deviation 72 s, variance 1.44 \times 3600 = 5184 square seconds. Here k = 60 and k^2 = 3600.
- Standard deviation 3 \times 2.5 = 7.5, variance 7.5^2 = 56.25, which is 9 \times 6.25.
- Mean 1.8 \times 3.5 + 32 = 38.3^\circ\text{F}, median 1.8 \times 3.2 + 32 = 37.76^\circ\text{F}, standard deviation 1.8 \times 0.5 = 0.9 and IQR 1.8 \times 1.0 = 1.8 Fahrenheit degrees.
- The rule is y = 1.1(x + 3) = 1.1x + 3.3. Mean 36.3, median 31.9, minimum 14.3, maximum 80.3, standard deviation 1.1 \times 6 = 6.6, range 1.1 \times 60 = 66 dollars.
- Mean 1.1 \times 30 + 3 = 36, median 1.1 \times 26 + 3 = 31.6 dollars. Every order is 0.30 dollars cheaper than in exercise 10, since there the fee itself was raised to 3.30.
- Mean 2 \times 12 - 5 = 19, standard deviation 2 \times 3 = 6, Q_1 = 13, Q_3 = 23, IQR 10, which is 2 \times 5.
- Mean 3 \times 3 + 2 = 11, variance 9 \times 2.5 = 22.5. The new values 5, 8, 14, 17 have mean \displaystyle \frac{44}{4} = 11 and deviations -6, -3, 3, 6, so variance \displaystyle \frac{90}{4} = 22.5.
- Mean \displaystyle \frac{39.2 - 32}{1.8} = 4^\circ\text{C}, median \displaystyle \frac{38.3 - 32}{1.8} = 3.5^\circ\text{C}, standard deviation \displaystyle \frac{1.08}{1.8} = 0.6 Celsius degrees.
- b = 2.5, a = -5. The standard deviation gives 10 = 4b; then 45 = 2.5 \times 20 + a.
- A 10\% increase after a 4 dollar fee; new mean 28.6 dollars. The IQR gives \displaystyle b = \frac{13.2}{12} = 1.1; then 1.1(19 + f) = 25.3 gives 19 + f = 23, f = 4; and 1.1(22 + 4) = 28.6.
- The standard deviation is built from the deviations x_i - \bar{x}. Adding 10 raises each value and the mean by 10, so (x_i + 10) - (\bar{x} + 10) = x_i - \bar{x}: every deviation, and so the standard deviation, is unchanged. The values moved, but not apart.
- With y_i = kx_i, \bar{y} = k\bar{x}, so y_i - \bar{y} = k(x_i - \bar{x}) and each squared deviation is k^2(x_i - \bar{x})^2. The mean of these is k^2 times the old variance. The standard deviation is the square root, and \displaystyle \sqrt{k^2 \sigma_x^2} = k\sigma_x since k > 0: the square undoes the square.