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

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

A Continuous Example Using Mean and Variance

Learn to normalize a bounded density and compute its mean, variance, and standard deviation step by step from integrals.

Beginner 9 min read

What You'll Learn

  • Find the normalization constant for a density specified up to a multiplicative constant.
  • Calculate the mean and second raw moment using integrals over the support.
  • Obtain variance from the second moment and the square of the mean.
  • Compute and interpret standard deviation in the variable’s units.
  • Check results for normalization, support, units, and nonnegative variance.

From a Bounded Density to Mean and Variance

For a continuous random variable, a density assigns probability across intervals rather than to individual points. To find its mean and variability, we integrate over the variable’s support. When a density is given only up to a constant, the first task is to determine that constant: every later calculation depends on using a correctly normalized density.

This tutorial works through bounded densities from normalization to standard deviation. The examples emphasize the setup and evaluation of each integral, along with checks that help detect an incorrect support, a missing constant, or an algebra error.

Definition: Suppose a continuous random variable \(X\) has density \(f_X(x)\) on a bounded interval \([a,b]\), and density zero outside that interval. The density must be nonnegative and satisfy \(\int_a^b f_X(x)\,dx=1\). Its mean and second raw moment are \(E[X]=\int_a^b x f_X(x)\,dx\) and \(E[X^2]=\int_a^b x^2 f_X(x)\,dx\). Its variance is \(\operatorname{Var}(X)=E[X^2]-(E[X])^2\), and its standard deviation is \(\sqrt{\operatorname{Var}(X)}\).

If the density is written as \(f_X(x)=c\,g(x)\) on \([a,b]\), first use the total-probability condition to find \(c\):

$$ 1=\int_a^b c\,g(x)\,dx \qquad\Longrightarrow\qquad c=\frac{1}{\int_a^b g(x)\,dx}, $$

provided \(g(x)\) is nonnegative on the stated support and its integral is positive and finite. After finding \(c\), use the resulting density—not the unnormalized function \(g\)—in the moment integrals. A density has units reciprocal to those of \(X\); probabilities are areas under the density and are dimensionless.

Why the Second Moment Gives the Variance

Variance measures the expected squared distance from the mean \(\mu=E[X]\). Thus, by definition, \(\operatorname{Var}(X)=E[(X-\mu)^2]\). For a bounded density, the expectation is an integral over its support. Expanding the square gives the computational formula:

$$ \begin{aligned} \operatorname{Var}(X) &=\int_a^b (x-\mu)^2 f_X(x)\,dx\\ &=\int_a^b \left(x^2-2\mu x+\mu^2\right)f_X(x)\,dx\\ &=E[X^2]-2\mu E[X]+\mu^2\int_a^b f_X(x)\,dx\\ &=E[X^2]-2\mu^2+\mu^2\\ &=E[X^2]-\mu^2. \end{aligned} $$

The fourth line uses both \(E[X]=\mu\) and \(\int_a^b f_X(x)\,dx=1\). This explains why normalization matters not only for probabilities but also for the variance formula. The variance has squared units; the standard deviation, obtained by taking its nonnegative square root, has the same units as \(X\).

Worked Examples

Worked Example: A Density Proportional to \(x\)

A hypothetical bounded measurement \(X\), in units, has density \(f_X(x)=cx\) for \(0\le x\le2\), and zero otherwise. Find \(c\), the mean, the second raw moment, the variance, and the standard deviation. Use exact values until the final standard-deviation calculation.

Method. Normalize first, then evaluate the first and second moment integrals. This avoids the common mistake of integrating \(x\) or \(x^2\) against \(cx\) before determining the density’s scale.

1. Find the constant. Since the total probability must be one,

$$ 1=\int_0^2 cx\,dx =c\left[\frac{x^2}{2}\right]_0^2 =c(2). \qquad\text{Therefore }c=\frac12. $$

The normalized density is \(f_X(x)=x/2\) on \([0,2]\). It is nonnegative there, and its integral is \((1/2)(2)=1\).

2. Find the mean.

$$ E[X]=\int_0^2 x\frac{x}{2}\,dx =\frac12\left[\frac{x^3}{3}\right]_0^2 =\frac12\cdot\frac83 =\frac43. $$

3. Find the second raw moment.

$$ E[X^2]=\int_0^2 x^2\frac{x}{2}\,dx =\frac12\left[\frac{x^4}{4}\right]_0^2 =\frac12\cdot4 =2. $$

4. Find variance and standard deviation.

$$ \operatorname{Var}(X)=2-\left(\frac43\right)^2 =2-\frac{16}{9} =\frac29, \qquad \operatorname{SD}(X)=\sqrt{\frac29} =\frac{\sqrt2}{3} \approx0.4714. $$

Check. The mean \(4/3\) lies in the support \([0,2]\), and the variance \(2/9\) is nonnegative. The standard deviation is reported to four decimal places. The common mistake avoided here is using \(\int_0^2 x^2\,dx\) for the second moment; the integrand must be \(x^2 f_X(x)\), including the density factor \(x/2\).

Worked Example: A Decreasing Linear Density

A hypothetical continuous score \(X\) has density \(f_X(x)=c(3-x)\) for \(0\le x\le3\), and zero otherwise. Calculate the normalization constant, mean, second raw moment, variance, and standard deviation.

Method. Integrate the kernel to normalize, then multiply it by \(x\) and \(x^2\) for the two moments. A frequent trap is to forget that the factor \(3-x\) remains in each moment integrand.

1. Normalize.

$$ 1=c\int_0^3(3-x)\,dx =c\left[3x-\frac{x^2}{2}\right]_0^3 =c\left(9-\frac92\right) =c\frac92, \qquad c=\frac29. $$

The density is nonnegative on \([0,3]\), and the calculated constant makes its integral one.

2. Calculate the mean.

$$ \begin{aligned} E[X] &=\frac29\int_0^3 x(3-x)\,dx\\ &=\frac29\left[\frac{3x^2}{2}-\frac{x^3}{3}\right]_0^3\\ &=\frac29\left(\frac{27}{2}-9\right) =\frac29\cdot\frac92 =1. \end{aligned} $$

3. Calculate the second raw moment.

$$ \begin{aligned} E[X^2] &=\frac29\int_0^3 x^2(3-x)\,dx\\ &=\frac29\left[x^3-\frac{x^4}{4}\right]_0^3\\ &=\frac29\left(27-\frac{81}{4}\right) =\frac29\cdot\frac{27}{4} =\frac32. \end{aligned} $$

4. Calculate variance and standard deviation.

$$ \operatorname{Var}(X)=\frac32-1^2=\frac12, \qquad \operatorname{SD}(X)=\sqrt{\frac12} =\frac{1}{\sqrt2} \approx0.7071. $$

Check. The mean \(1\) is within the support, and the variance is positive. The standard deviation is rounded to four decimal places. If the factor \(3-x\) were omitted from the moment integrals, the resulting values would not describe this density.

Worked Example: A Symmetric Quadratic Density on a Wider Interval

A hypothetical continuous quantity \(X\), measured in units, has density \(f_X(x)=cx(4-x)\) for \(0\le x\le4\), and zero otherwise. Find all five requested quantities: \(c\), \(E[X]\), \(E[X^2]\), \(\operatorname{Var}(X)\), and the standard deviation.

Method. Normalize the quadratic kernel, then evaluate each moment directly. The support is wider than in the previous examples, so retain the endpoints carefully when evaluating the antiderivatives.

1. Normalize.

$$ \begin{aligned} 1 &=c\int_0^4 x(4-x)\,dx =c\int_0^4(4x-x^2)\,dx\\ &=c\left[2x^2-\frac{x^3}{3}\right]_0^4 =c\left(32-\frac{64}{3}\right) =c\frac{32}{3}. \end{aligned} \qquad c=\frac{3}{32}. $$

The kernel \(x(4-x)\) is nonnegative throughout \([0,4]\), so this constant gives a valid nonnegative density.

2. Find the mean.

$$ \begin{aligned} E[X] &=\frac{3}{32}\int_0^4 x^2(4-x)\,dx =\frac{3}{32}\int_0^4(4x^2-x^3)\,dx\\ &=\frac{3}{32}\left[\frac{4x^3}{3}-\frac{x^4}{4}\right]_0^4 =\frac{3}{32}\left(\frac{256}{3}-64\right)\\ &=\frac{3}{32}\cdot\frac{64}{3}=2. \end{aligned} $$

3. Find the second raw moment.

$$ \begin{aligned} E[X^2] &=\frac{3}{32}\int_0^4 x^3(4-x)\,dx =\frac{3}{32}\int_0^4(4x^3-x^4)\,dx\\ &=\frac{3}{32}\left[x^4-\frac{x^5}{5}\right]_0^4 =\frac{3}{32}\left(256-\frac{1024}{5}\right)\\ &=\frac{3}{32}\cdot\frac{256}{5} =\frac{24}{5}. \end{aligned} $$

4. Find variance and standard deviation.

$$ \operatorname{Var}(X)=\frac{24}{5}-2^2 =\frac{24}{5}-\frac{20}{5} =\frac45, \qquad \operatorname{SD}(X)=\sqrt{\frac45} =\frac{2}{\sqrt5} \approx0.8944. $$

Check. The density integrates to one, the mean \(2\) lies in \([0,4]\), and the variance is positive. The standard deviation is rounded to four decimal places. The common mistake avoided is subtracting the mean, rather than its square, from the second raw moment.

Checks That Make the Calculation More Reliable

A continuous mean and variance calculation is a sequence of related integrals. A correct-looking final number can still come from an incorrect density or a misplaced endpoint, so check the work at each stage:

  • Check the density. The constant should make the integral over the full support equal to one, and the density should not be negative on that support.
  • Check the integrands. For the mean, use \(x f_X(x)\); for the second raw moment, use \(x^2 f_X(x)\). Do not integrate the powers of \(x\) alone.
  • Check the mean’s location. For a density supported on \([a,b]\), the mean must lie between \(a\) and \(b\).
  • Check variance and units. Variance must be nonnegative and is in squared units. Standard deviation is its nonnegative square root and is in the original units.

The computational formula is convenient, but the central definition remains \(\operatorname{Var}(X)=E[(X-E[X])^2]\). Squared deviations cannot average to a negative value; if \(E[X^2]-(E[X])^2\) is negative, revisit the normalization and moment arithmetic. These steps are aligned with the SOA VEE Mathematical Statistics syllabus.

Check Your Understanding

For each density, find the normalization constant, mean, second raw moment, variance, and standard deviation. Give standard deviations to four decimal places.

  1. A density is \(f_X(x)=c\) on \(0\le x\le5\), and zero otherwise. (Answer: \(c=1/5\), \(E[X]=5/2\), \(E[X^2]=25/3\), \(\operatorname{Var}(X)=25/12\), standard deviation \(1.4434\).)
  2. A density is \(f_X(x)=cx^2\) on \(0\le x\le2\), and zero otherwise. (Answer: \(c=3/8\), \(E[X]=3/2\), \(E[X^2]=12/5\), \(\operatorname{Var}(X)=3/20\), standard deviation \(0.3873\).)
  3. A density is \(f_X(x)=c(2-x)\) on \(0\le x\le2\), and zero otherwise. (Answer: \(c=1/2\), \(E[X]=2/3\), \(E[X^2]=2/3\), \(\operatorname{Var}(X)=2/9\), standard deviation \(0.4714\).)
  4. A density is \(f_X(x)=cx(2-x)\) on \(0\le x\le2\), and zero otherwise. (Answer: \(c=3/4\), \(E[X]=1\), \(E[X^2]=6/5\), \(\operatorname{Var}(X)=1/5\), standard deviation \(0.4472\).)
  5. A density is \(f_X(x)=c(1+x)\) on \(-1\le x\le1\), and zero otherwise. (Answer: \(c=1/2\), \(E[X]=1/3\), \(E[X^2]=1/3\), \(\operatorname{Var}(X)=2/9\), standard deviation \(0.4714\).)
Clinical Biostats