Sub topic 10
Shifting and scaling a variable
This chapter assumes you know the mean and standard deviation of a data set, and that you can read the expected value and variance of a random variable as defined in earlier chapters. It also assumes you are comfortable with the z-score formula. Here you learn what happens to the mean and spread when every value is changed by the same arithmetic rule. GRE questions use this often, for example when scores are curved, units are converted, or a quantity is rescaled.
The setup: Y = aX + b
Suppose X is a random variable with mean μ and standard deviation σ. Build a new variable from it:
Y = aX + b
Here a and b are fixed numbers. Multiplying by a is scaling. Adding b is shifting. Every value of X is changed by the same rule, so the whole distribution is moved and stretched together.
The rules are:
| Quantity | Value for Y = aX + b | Column | Column |
|---|---|---|---|
| Mean | aμ + b | ||
| Standard deviation | \ | a\ | · σ |
| Variance | a² · σ² |
The mean follows the full rule, so it is both scaled and shifted. The spread ignores b and uses only the size of a.
Why shifting does not change spread
Adding b to every value moves each value and the mean by the same amount. The distance between a value and the mean stays the same. Variance and standard deviation are built from those distances, so they do not change.
Consider the data 2, 4, 6. The mean is 4, and the distances from the mean are −2, 0, 2. Add 10 to every value to get 12, 14, 16. The mean is now 14, and the distances are still −2, 0, 2.
Shifting also leaves the range and the gaps between values unchanged. The median shifts by b, just like the mean.
Why scaling does change spread
Multiplying every value by a multiplies every distance from the mean by a. The standard deviation measures typical distance, so it is multiplied by |a|. The variance is built from squared distances, so it is multiplied by a².
This difference matters on the exam. If every value triples, the standard deviation triples but the variance becomes nine times as large.
A worked example with a data set
Take the data 2, 4, 4, 4, 5, 5, 7, 9. The mean is 5. The squared distances from the mean are 9, 1, 1, 1, 0, 0, 4, 16, which sum to 32. Dividing by 8 gives a variance of 4, so the standard deviation is 2.
Now form Y = 3X − 4. The rules predict a mean of 3(5) − 4 = 11 and a standard deviation of 3 · 2 = 6. This code checks the prediction.
from statistics import mean, pstdev
x = [2, 4, 4, 4, 5, 5, 7, 9]
y = [3 * v - 4 for v in x]
print(mean(x), pstdev(x)) # 5 2.0
print(mean(y), pstdev(y)) # 11 6.0The computed values match the predictions. The -4 shifted the mean and had no effect on the spread.
The same rules for a random variable
The rules hold for a random variable as well as for a data set. In the earlier example, X has mean 50 and standard deviation 8. For Y = 2X + 10, the mean is 2(50) + 10 = 110. The standard deviation is |2| · 8 = 16.
mean_x = 50
sd_x = 8
# Y = 2X + 10
mean_y = 2 * mean_x + 10
sd_y = abs(2) * sd_x
print(mean_y, sd_y) # 110 16The code uses abs(2) so the formula is the same one you would use for a negative multiplier.
Negative multipliers
A negative a flips the distribution. Large values become small and small values become large. The mean flips with the values, but the spread is a distance, so it cannot be negative.
Let X have mean 20 and standard deviation 4, and let Y = 100 − 3X. Here a = −3 and b = 100.
- Mean of Y: −3(20) + 100 = 40.
- Standard deviation of Y: |−3| · 4 = 12.
- Variance of Y: (−3)² · 16 = 144, which is 12².
A standard deviation of −12 is impossible.
Real conversions
Unit changes are linear transformations, so the rules apply directly. Temperature is a good example, because it uses both a scale and a shift: F = 1.8C + 32.
Suppose daily high temperatures have a mean of 20 °C and a standard deviation of 5 °C. In Fahrenheit, the mean is 1.8(20) + 32 = 68 °F. The standard deviation is 1.8 · 5 = 9 °F. The 32 does not enter the spread calculation.
mean_c = 20
sd_c = 5
mean_f = 1.8 * mean_c + 32
sd_f = abs(1.8) * sd_c
print(round(mean_f, 1), round(sd_f, 1)) # 68.0 9.0Curving scores: add or multiply?
A teacher can raise a class's scores in two ways, and they affect spread differently.
- Add 5 points to everyone. The mean rises by 5 and the standard deviation is unchanged.
- Multiply everyone's score by 1.1 (a 10% increase). The mean rises by 10% and the standard deviation also rises by 10%. Higher scores gain more points, so the scores spread out.
The words in a GRE problem tell you which rule applies. "Increased by 5" is a shift. "Increased by 10 percent" or "doubled" is a scale. A statement like "each value is doubled and then 3 is added" means Y = 2X + 3, in that order. The order matters: doubling after adding 3 gives 2(X + 3) = 2X + 6, which has a different b.
Normal stays normal
If X is normally distributed, then Y = aX + b is also normally distributed when a ≠ 0. Only the parameters change. You can therefore use the empirical rule and z-scores on Y after finding its new mean and standard deviation.
Example: heights X are normal with mean 66 inches and standard deviation 4 inches. In centimeters, with 1 inch = 2.54 cm, the heights are normal with mean 66(2.54) = 167.64 cm and standard deviation 4(2.54) = 10.16 cm. About 68% of heights fall within 10.16 cm of 167.64 cm.
Z-scores are a linear transformation
The z-score formula is z = (x − μ)/σ. Rewrite it as
z = (1/σ)x − μ/σ
This has the form aX + b with a = 1/σ and b = −μ/σ. Apply the rules:
- Mean: (1/σ)μ − μ/σ = 0.
- Standard deviation: (1/σ) · σ = 1.
Converting to z-scores always gives a variable with mean 0 and standard deviation 1. If X is normal, Z is the standard normal. The shift by −μ centers the distribution at zero. The division by σ makes one standard deviation equal to one unit.
You can also run this in reverse to move a value onto a new scale. Suppose scores have mean 500 and standard deviation 100, and a score of 650 is converted to a scale with mean 50 and standard deviation 10. The z-score is 1.5 on both scales, so the new value is 50 + 1.5(10) = 65.
What stays the same, and what does not
When a > 0, a linear transformation keeps every value in the same order. A value at the 84th percentile of X is at the 84th percentile of Y. Percentiles and z-scores are preserved. This is why a z-score gives the same answer in any unit.
When a < 0, the order reverses. A value at the 84th percentile of X lands at the 16th percentile of Y. The z-score of the corresponding value changes sign.
| Statistic | Shift by b | Scale by a | Column | Column |
|---|---|---|---|---|
| Mean, median | Shifts by b | Multiplies by a | ||
| Standard deviation, range, IQR | Unchanged | Multiplies by \ | a\ | |
| Variance | Unchanged | Multiplies by a² | ||
| Z-score of a given value | Unchanged | Unchanged if a > 0, sign flips if a < 0 |
Pitfalls
Two more cases to keep in mind:
- Multiplying by a = 0 makes every value b. The variable no longer varies, and its standard deviation is 0. The result is not normal.
- Adding two different variables, such as X + Y, is a different problem. The mean of a sum is the sum of the means, but the spread of a sum needs extra information that this chapter does not cover. Shifting and scaling apply to one variable at a time.
Exercise
Test scores are normally distributed with mean 70 and standard deviation 10. Each score is multiplied by 1.2, and then 5 is subtracted. What are the new mean and standard deviation?
Show answer
The new score is Y = 1.2X − 5. The mean is 1.2(70) − 5 = 79. The standard deviation is 1.2 · 10 = 12. The subtraction of 5 does not change the spread.
Exercise
A variable X has mean 20 and variance 16. Find the mean and variance of Y = 100 − 3X.
Show answer
The mean is −3(20) + 100 = 40. The variance is (−3)² · 16 = 144. The standard deviation is 12, which is |−3| times the original standard deviation of 4.
Exercise
Exam scores X have mean 500 and standard deviation 100. A student scores 650. The scores are rescaled to a new scale with mean 50 and standard deviation 10. What is the student's new score, and what percent of scores are below it, using the empirical rule? (Assume a normal distribution and give the answer as a range from the rule.)
Show answer
The z-score is (650 − 500)/100 = 1.5, which is the same on the new scale. The new score is 50 + 1.5(10) = 65. A z-score of 1.5 lies between 1 and 2 standard deviations above the mean. About 84% of scores are below z = 1 and about 97.5% are below z = 2, so the percentile is between 84% and 97.5%. (The exact value is about 93%.)