Tutorials › VEE Mathematical Statistics › A Discrete Example Using Mean and Variance

VEE Mathematical Statistics · Expectation and Variability · Tutorial 70 of 880

A Discrete Example Using Mean and Variance

Learn to calculate and interpret the mean and variability of a finite discrete random variable, and to check the results for consistency.

Beginner 10 min read

What You'll Learn

  • Organize finite support values and probabilities in a calculation table.
  • Calculate the mean and raw second moment from a probability mass function.
  • Find variance using the computational formula and verify it with squared deviations.
  • Interpret standard deviation in the units of the random variable.
  • Check calculations against the support and avoid common moment-calculation errors.

From a Finite Probability Model to Variability

For a discrete random variable with only a few possible values, its probability mass function gives a direct route to both its center and its spread. The mean summarizes the probability-weighted location of the outcomes. The variance and standard deviation describe how far outcomes tend to lie from that mean. In a finite model, each quantity can be calculated with a short table, making it possible to check every contribution rather than rely on a shortcut.

The main care points are to use each probability with its matching outcome, square the outcome when calculating the raw second moment, and square the mean in the computational variance formula. These details matter because the raw second moment and variance are measured in squared units, while the standard deviation returns to the original units.

Definition: Suppose a discrete random variable \(X\) has distinct possible values \(x_1,\ldots,x_n\), with probabilities \(p_i=P(X=x_i)\). A finite probability model has \(p_i\geq 0\) for every \(i\), and \(\sum_{i=1}^{n}p_i=1\). Its support is the set of possible values with positive probability. The mean, raw second moment, variance, and standard deviation are $$ E[X]=\sum_{i=1}^{n}x_i p_i,\qquad E[X^2]=\sum_{i=1}^{n}x_i^2p_i, $$ $$ \operatorname{Var}(X)=E[(X-E[X])^2]=E[X^2]-(E[X])^2,\qquad \operatorname{SD}(X)=\sqrt{\operatorname{Var}(X)}. $$

These formulas assume the stated values and probabilities describe the entire distribution. A finite distribution has finite moments, so the sums exist. If a table omits a possible outcome or its probabilities do not sum to one, it is not yet a valid complete probability model and the calculations should not proceed until the issue is resolved.

A Reliable Calculation Layout

A useful table includes the outcome, its probability, the contribution to the mean, and the contribution to the raw second moment. The last two columns are \(x_i p_i\) and \(x_i^2p_i\), respectively. Keeping them separate helps prevent confusing \(E[X^2]\) with \((E[X])^2\): the former averages the squared outcomes, whereas the latter squares the already-calculated mean.

1
Validate the model.
Check that the listed outcomes cover the support and that the probabilities are nonnegative and sum to one.
2
Calculate the mean.
Multiply each outcome by its probability and add the products.
3
Calculate the raw second moment.
Square each outcome first, multiply by its probability, and add those products.
4
Obtain and interpret the spread.
Subtract the square of the mean from the raw second moment; then take the nonnegative square root for standard deviation.

Worked Example: Hypothetical Claim Payments

A hypothetical insurance payment \(X\), in dollars, has possible values \(0\), \(100\), and \(200\), with probabilities \(0.20\), \(0.50\), and \(0.30\), respectively. Find the mean payment, raw second moment, variance, and standard deviation. Treat these probabilities as the complete model; no interest or mortality assumption is involved.

Method and model check. This is a finite discrete distribution. The probabilities are nonnegative and sum to \(0.20+0.50+0.30=1.00\), so the table is a valid probability mass function.

\(x_i\) (dollars)\(p_i\)\(x_i p_i\)\(x_i^2p_i\) (dollars squared)
00.2000
1000.50505,000
2000.306012,000
Total1.0011017,000

Mean. Add the weighted outcomes:

$$ E[X]=(0)(0.20)+(100)(0.50)+(200)(0.30)=0+50+60=\$110. $$

Raw second moment. Square each payment before weighting:

$$ E[X^2]=(0^2)(0.20)+(100^2)(0.50)+(200^2)(0.30) =0+5{,}000+12{,}000=17{,}000\text{ dollars}^2. $$

Variance and standard deviation. Apply the computational formula:

$$ \operatorname{Var}(X)=17{,}000-(110)^2 =17{,}000-12{,}100=4{,}900\text{ dollars}^2, $$ $$ \operatorname{SD}(X)=\sqrt{4{,}900}=\$70. $$

Check and common mistake avoided. The mean, \(\$110\), lies between the smallest and largest possible payments, \(\$0\) and \(\$200\). The variance is nonnegative, and the standard deviation is in dollars rather than dollars squared. A common mistake would be to report \(17{,}000\) as the variance; that is the raw second moment. Subtracting the squared mean gives the variance, \(\$4{,}900\) squared.

Why the Computational Formula Works

The variance is defined as the expected squared distance from the mean. For a finite distribution, this definition can be expanded directly. Write \(\mu=E[X]\). Since \(\mu\) is a constant, the squared deviation at an outcome \(x_i\) is \(x_i^2-2\mu x_i+\mu^2\). Weighting each deviation by its probability and summing gives

$$ \begin{aligned} \operatorname{Var}(X) &=\sum_{i=1}^{n}(x_i-\mu)^2p_i\\ &=\sum_{i=1}^{n}(x_i^2-2\mu x_i+\mu^2)p_i\\ &=\sum_{i=1}^{n}x_i^2p_i-2\mu\sum_{i=1}^{n}x_i p_i +\mu^2\sum_{i=1}^{n}p_i\\ &=E[X^2]-2\mu E[X]+\mu^2\\ &=E[X^2]-2\mu^2+\mu^2\\ &=E[X^2]-(E[X])^2. \end{aligned} $$

The penultimate line uses both defining properties of the model: \(\sum_i x_i p_i=E[X]=\mu\) and \(\sum_i p_i=1\). This also explains why it is the square of the mean that is subtracted, not the mean itself.

The definition and computational formula give the same result, but the computational formula is often faster. For a small support, the weighted squared deviations also provide a useful independent check: calculate \((x_i-\mu)^2p_i\) for each outcome and verify that their sum equals \(E[X^2]-(E[X])^2\).

Worked Example: A Discrete Inspection Delay

In a hypothetical scheduling model, inspection delay \(X\) is measured in minutes and can be \(0\), \(10\), \(20\), or \(30\). The corresponding probabilities are \(0.10\), \(0.20\), \(0.40\), and \(0.30\). Find \(E[X]\), \(E[X^2]\), the variance, and the standard deviation, and verify the variance using squared deviations.

Method and model check. The probabilities sum to \(0.10+0.20+0.40+0.30=1.00\). The model therefore covers a finite support with valid probabilities.

\(x_i\) (minutes)\(p_i\)\(x_i p_i\)\(x_i^2p_i\) (minutes squared)
00.1000
100.20220
200.408160
300.309270
Total1.0019450

The mean delay is \(0+2+8+9=19\) minutes, and the raw second moment is \(0+20+160+270=450\) minutes squared. Thus

$$ \operatorname{Var}(X)=450-19^2=450-361=89\text{ minutes}^2, \qquad \operatorname{SD}(X)=\sqrt{89}\approx 9.43\text{ minutes}. $$

For an independent check, the weighted squared deviations are

$$ \begin{aligned} \sum_i(x_i-19)^2p_i &=(0-19)^2(0.10)+(10-19)^2(0.20)\\ &\quad +(20-19)^2(0.40)+(30-19)^2(0.30)\\ &=36.1+16.2+0.4+36.3=89\text{ minutes}^2. \end{aligned} $$

The mean of \(19\) minutes lies within the support from \(0\) to \(30\) minutes, and both variance calculations agree. The standard deviation is rounded to two decimal places. The common mistake avoided here is treating the raw second moment, \(450\), as though it were the variance; the squared mean, \(361\), must be subtracted.

Interpreting the Results and Checking the Support

The mean is a probability-weighted balance point, not necessarily a possible outcome. For a finite support with minimum \(a\) and maximum \(b\), it must satisfy \(a\leq E[X]\leq b\). A result outside that range signals a likely error in the probabilities, the outcome-probability pairings, or the arithmetic. The mean need not equal the most likely outcome.

Variance is an average of squared deviations, so it cannot be negative. It is zero exactly when every outcome with positive probability equals the mean; otherwise it is positive. Variance has squared units, such as dollars squared or minutes squared. Standard deviation is the nonnegative square root of variance and therefore uses the same units as \(X\). It describes a typical scale of distance from the mean, but it is not a guarantee that every outcome lies within one standard deviation.

Worked Example: A Finite Count With an Unusual Support

A hypothetical weekly service desk count \(X\) records the number of escalated cases. Its only possible values are \(0\), \(1\), \(2\), and \(4\), with probabilities \(0.25\), \(0.25\), \(0.40\), and \(0.10\), respectively. Find the four summary quantities and check the variance by the definition. The value \(3\) is not possible under this model.

Method and model check. The stated probabilities are nonnegative and sum to \(0.25+0.25+0.40+0.10=1.00\). Use exactly the listed support values; do not insert an outcome of \(3\).

\(x_i\)\(p_i\)\(x_i p_i\)\(x_i^2p_i\)
00.2500
10.250.250.25
20.400.801.60
40.100.401.60
Total1.001.453.45

Therefore, \(E[X]=1.45\) cases and \(E[X^2]=3.45\) cases squared. The variance is

$$ \operatorname{Var}(X)=3.45-(1.45)^2 =3.45-2.1025=1.3475\text{ cases}^2, $$ $$ \operatorname{SD}(X)=\sqrt{1.3475}\approx1.16\text{ cases}. $$

To check by squared deviations, the four contributions are

$$ \begin{aligned} (0-1.45)^2(0.25)&=0.525625,\\ (1-1.45)^2(0.25)&=0.050625,\\ (2-1.45)^2(0.40)&=0.121,\\ (4-1.45)^2(0.10)&=0.65025. \end{aligned} $$

Their sum is \(0.525625+0.050625+0.121+0.65025=1.3475\), matching the computational formula. The mean lies between the support endpoints, \(0\) and \(4\). Rounding the standard deviation to two decimal places gives \(1.16\) cases. The key trap is to assume that integer values between the endpoints must all be possible; the calculation uses only the support specified by the model.

Common Calculation Traps

  • Using the wrong probability with an outcome. Preserve each outcome-probability pairing from the model when setting up the calculation table.
  • Forgetting to square the outcome. In the raw second moment, the contribution is \(x_i^2p_i\), not \(x_i p_i\) and not \((x_i p_i)^2\).
  • Subtracting the mean instead of its square. The variance is \(E[X^2]-(E[X])^2\). For the inspection-delay model, subtracting \(19\) from \(450\) would give \(431\), not the correct variance of \(89\).
  • Mixing units. If \(X\) is measured in dollars, \(E[X]\) and \(\operatorname{SD}(X)\) are in dollars, while \(E[X^2]\) and \(\operatorname{Var}(X)\) are in dollars squared.
  • Skipping the final checks. Confirm probabilities sum to one, the mean lies within the support, the variance is nonnegative, and the square root returns to the original units.
Key takeaway: For a finite discrete model, calculate \(E[X]\) from weighted outcomes and \(E[X^2]\) from weighted squared outcomes. Then use \(\operatorname{Var}(X)=E[X^2]-(E[X])^2\) and take its square root for standard deviation. A probability check, a support check, and a units check make the result easier to trust.

Check Your Understanding

For each finite model, calculate the mean, raw second moment, variance, and standard deviation. Answers give the standard deviation to two decimal places where it is not exact.

  1. A hypothetical payment \(X\) can be \(0\), \(2\), or \(6\) dollars, with probabilities \(0.50\), \(0.25\), and \(0.25\). Find all four quantities. (Answer: \(E[X]=2\), \(E[X^2]=10\), \(\operatorname{Var}(X)=6\), \(\operatorname{SD}(X)=\sqrt{6}\approx2.45\).)
  2. A discrete measurement \(X\) takes values \(1\), \(2\), and \(4\) units with probabilities \(0.20\), \(0.50\), and \(0.30\). Find all four quantities and state the units for the second moment and variance. (Answer: \(E[X]=2.4\), \(E[X^2]=7\) units squared, \(\operatorname{Var}(X)=1.24\) units squared, \(\operatorname{SD}(X)\approx1.11\) units.)
  3. A hypothetical count \(X\) takes values \(0\), \(5\), and \(10\) with probabilities \(0.30\), \(0.40\), and \(0.30\). Find all four quantities and check whether the mean is a possible outcome. (Answer: \(E[X]=5\), \(E[X^2]=40\), \(\operatorname{Var}(X)=15\), \(\operatorname{SD}(X)=\sqrt{15}\approx3.87\); the mean is a possible outcome.)
  4. A count \(X\) has support \(0,1,3\) with probabilities \(0.40,0.40,0.20\). Calculate the moments and variance, then identify whether \(2\) belongs in the calculation. (Answer: \(E[X]=1\), \(E[X^2]=2.2\), \(\operatorname{Var}(X)=1.2\), \(\operatorname{SD}(X)\approx1.10\); \(2\) is not in the stated support and is not included.)
  5. A hypothetical benefit payment \(X\), in dollars, is \(0\), \(100\), or \(300\), with probabilities \(0.40\), \(0.40\), and \(0.20\). Find the mean, raw second moment, variance, and standard deviation. (Answer: \(E[X]=\$100\), \(E[X^2]=22{,}000\) dollars squared, \(\operatorname{Var}(X)=12{,}000\) dollars squared, \(\operatorname{SD}(X)\approx\$109.54\).)
Clinical Biostats