2.5 Variance and Standard Deviation =================================== :bolditalic:`Key Terms` :bolditalic:`Variability(變異性)` The amount of spread in a probability distribution. :bolditalic:`Deviation(離差)` The difference between a value and the mean. :bolditalic:`Variance(變異數)` The probability-weighted average squared deviation from the mean. :bolditalic:`Standard deviation(標準差)` The positive square root of the variance. :bolditalic:`Spread(離散程度)` How far values tend to vary around the mean. 2.5.2 Learning Outcomes ----------------------- After completing this section, students should be able to: - explain why the mean alone does not fully describe a probability distribution; - interpret variance as spread around the mean; - calculate variance and standard deviation for a discrete random variable; - calculate variance and standard deviation for a simple continuous random variable; - explain why deviations are squared; - explain why two distributions can have the same mean but different spread; - use the computational formula :math:`E(X^2)-[E(X)]^2`. 2.5.3 Center Does Not Describe Spread ------------------------------------- The mean describes where a probability distribution balances, but it does not describe how widely probability is spread around that balance point. Consider two discrete random variables with the same mean :math:`\mu=5`. For :math:`X`, .. math:: P(X=2)=\frac12, \qquad P(X=8)=\frac12. For :math:`Y`, .. math:: P(Y=4)=\frac12, \qquad P(Y=6)=\frac12. Both distributions balance at 5, but :math:`X` places probability much farther from the mean. .. image:: ../_static/figures/random_variables/figure_2_5_1_same_mean_different_variance.png :width: 70% :align: center :alt: Two probability loadings with the same mean but different variance, with the first distribution more spread out than the second. The loading analogy from the previous section can therefore be extended: mean -> balance point variance -> how far the probability loading is spread around the balance point. For these two distributions, .. math:: \operatorname{Var}(X)=9, \qquad \operatorname{Var}(Y)=1. The mean is the same, but the variance is not. 2.5.4 Deviations from the Mean ------------------------------ For a value :math:`x`, its deviation from the mean is .. math:: x-\mu. A positive deviation lies above the mean and a negative deviation lies below the mean. If deviations were simply averaged, positive and negative values could cancel. Variance avoids this cancellation by squaring each deviation. .. image:: ../_static/figures/random_variables/figure_2_5_2_deviations_from_mean.png :width: 68% :align: center :alt: A probability loading with distances from two values to the mean indicated as absolute deviations. The squared quantity .. math:: (x-\mu)^2 is always nonnegative. It also gives greater influence to values that are far from the mean. 2.5.5 Variance of a Discrete Random Variable -------------------------------------------- For a discrete random variable with PMF :math:`p(x)`, variance is .. note:: **Discrete Variance** .. math:: \operatorname{Var}(X) = \sigma^2 = E[(X-\mu)^2] = \sum_x (x-\mu)^2p(x). The calculation is a probability-weighted average of squared deviations. Values with larger probability contribute more, and values farther from the mean contribute more because their deviations are squared. 2.5.6 Example 1: Uncertain Revenue ---------------------------------- Suppose a product design has revenue :math:`X`, measured in millions of dollars, with .. math:: P(X=2)=0.70, \qquad P(X=7)=0.30. Its expected revenue is .. math:: \mu=E(X)=2(0.70)+7(0.30)=3.5. The variance is .. math:: \operatorname{Var}(X) = (2-3.5)^2(0.70) + (7-3.5)^2(0.30) = 5.25. Because revenue is measured in millions of dollars, variance is measured in squared millions of dollars. 2.5.7 Standard Deviation ------------------------ The **standard deviation** is the positive square root of variance: .. math:: \sigma = \sqrt{\operatorname{Var}(X)}. For the revenue example, .. math:: \sigma = \sqrt{5.25} \approx 2.29. Unlike variance, standard deviation is expressed in the same units as the random variable. It is therefore often easier to interpret as a measure of spread. 2.5.8 Variance of a Continuous Random Variable ---------------------------------------------- The same idea applies to a continuous distribution. The summation is replaced by integration. .. note:: **Continuous Variance** For a continuous random variable with PDF :math:`f(x)`, .. math:: \operatorname{Var}(X) = \sigma^2 = \int_{-\infty}^{\infty}(x-\mu)^2f(x)\,dx. A narrow density places most probability near the mean and therefore tends to have a smaller standard deviation. A wider density places more probability farther from the mean. .. image:: ../_static/figures/random_variables/figure_2_5_3_continuous_same_mean_different_spread.png :width: 62% :align: center :alt: Two continuous density curves with the same mean, where one is narrow and the other is more spread out. The two curves in the figure have the same mean. Their different widths show that equal means do not imply equal standard deviations. 2.5.9 Example 2: Uniform Waiting Time ------------------------------------- Continue the waiting-time example from the previous section. Suppose .. math:: f(x)=\frac{1}{10}, \qquad 0\leq x\leq10, and :math:`f(x)=0` otherwise. The mean is .. math:: \mu=E(X)=5. The variance is .. math:: \operatorname{Var}(X) = \int_0^{10}(x-5)^2\frac{1}{10}\,dx = \frac{25}{3}. Therefore, .. math:: \sigma = \sqrt{\frac{25}{3}} = \frac{5}{\sqrt{3}} \approx 2.89\text{ minutes}. The variance has units of minutes squared, while the standard deviation is again measured in minutes. 2.5.10 Computational Formula ---------------------------- An equivalent and often more convenient formula is .. note:: **Variance Shortcut** .. math:: \operatorname{Var}(X) = E(X^2)-[E(X)]^2. For a discrete random variable, .. math:: E(X^2)=\sum_x x^2p(x). For a continuous random variable, .. math:: E(X^2)=\int_{-\infty}^{\infty}x^2f(x)\,dx. The direct formula emphasizes the meaning of variance as squared distance from the mean. The shortcut is often easier for calculation. 2.5.11 Interpreting Variance and Standard Deviation --------------------------------------------------- For variables measured in the same units: - smaller variance or standard deviation means greater concentration around the mean; - larger variance or standard deviation means greater spread around the mean; - variance 0 means the random variable takes one constant value with probability 1. Variance cannot be negative because it is formed from nonnegative squared deviations and nonnegative probability weights: .. math:: \operatorname{Var}(X)\geq0. Standard deviation is often easier to interpret numerically because it uses the same units as :math:`X`. 2.5.12 A Simple Method ---------------------- To calculate variance directly: 1. Find :math:`\mu=E(X)`. 2. Find the deviation :math:`x-\mu`. 3. Square the deviation. 4. Weight by the PMF or PDF. 5. Sum or integrate over all possible values. 6. Take the square root if standard deviation is required. Alternatively, calculate .. math:: E(X^2)-[E(X)]^2. 2.5.13 Common Mistakes ---------------------- Do not calculate :math:`E(X^2)-E(X)`; the mean must also be squared. Do not forget the probability weights :math:`p(x)` or density :math:`f(x)`. Do not confuse variance with standard deviation. Variance is :math:`\sigma^2`; standard deviation is :math:`\sigma`. Do not assume that equal means imply equal spread. Do not interpret variance in the original units of :math:`X`; variance uses squared units. 2.5.14 Summary -------------- The mean describes the balance point of a probability distribution. Variance and standard deviation describe its spread around that point. For a discrete random variable, .. math:: \operatorname{Var}(X) = \sum_x(x-\mu)^2p(x). For a continuous random variable, .. math:: \operatorname{Var}(X) = \int_{-\infty}^{\infty}(x-\mu)^2f(x)\,dx. In both cases, .. math:: \sigma=\sqrt{\operatorname{Var}(X)} and .. math:: \operatorname{Var}(X)=E(X^2)-[E(X)]^2. The main relationship is Mean -> center / balance point Variance and standard deviation -> spread around the mean .. 2.5.15 Short Review Questions .. ----------------------------- .. 1. Why is the mean alone not enough to describe a distribution? .. 2. Why are deviations from the mean squared? .. 3. What is the difference between variance and standard deviation? .. 4. Can two distributions have the same mean but different variance? .. 5. Why is standard deviation often easier to interpret than variance?