Tutorials › Generalized Linear Models › Probability Densities For Continuous Responses

Probability Models for Responses · Tutorial 4 of 981

Probability Densities For Continuous Responses

Define and check a probability density, then use its integrals to calculate probabilities for intervals of continuous responses.

Beginner 9 min read

What You'll Learn

  • State the integration rule that defines a density for a continuous response
  • Check that a proposed density is nonnegative and has total integral one
  • Find interval probabilities by integrating over the interval
  • Handle intervals that cross pieces of a piecewise density
  • Explain why changing interval endpoints does not change an interval probability

From Possible Values to Probability

A continuous response can take values across a range rather than only from a list of separate possibilities. For such a response, probability is assigned to sets of values by integrating a function over those sets. The function is called a probability density. Its integral over an interval gives the probability that the response falls in that interval.

This is different from assigning a probability directly to each individual value. A density is a function whose accumulated area over a region determines probability. The definition below makes that rule precise and gives two immediate checks for a proposed density: it must be nonnegative (apart from irrelevant changes on sets of length zero) and its total integral must be one.

Definition: A measurable function \(f:\mathbb{R}\to[0,\infty]\) is a probability density for a real-valued random variable \(X\) if, for every Borel set \(A\subseteq\mathbb{R}\), $$ P(X\in A)=\int_A f(x)\,dx. $$ In particular, \(\int_{\mathbb{R}}f(x)\,dx=1\). The integral is with respect to length on the real line. A function that is negative on a set of positive length cannot be a probability density.

The formula applies to any Borel set, including intervals. For an interval with endpoints \(a\leq b\), it gives

$$ P(a\leq X\leq b)=\int_a^b f(x)\,dx. $$

If a response can only take values in a specified range, the density contributes no probability outside that range: its integral there must be zero. A density may be defined as zero outside the range, which makes the integral over all real numbers straightforward to check.

Checking a Proposed Density

Two checks are central. First, \(f(x)\) must be nonnegative except possibly on a set of length zero. Second, its integral over the entire real line must equal one. The first condition ensures that integrals produce nonnegative probabilities; the second ensures that the probability of the whole possible-value space is one.

For a density given by a formula on a bounded interval, the normalization check is often an ordinary definite integral. For a density on an unbounded interval, an improper integral is used, with the limit evaluated explicitly. In either case, checking only that the formula looks positive is not enough: its total integral must also be exactly one.

Worked Example: A Density Increasing Across an Interval

Consider the function \(f(x)=2x\) for \(0\leq x\leq 1\), and \(f(x)=0\) otherwise. Check whether it is a density, then calculate \(P(1/4\leq X\leq 3/4)\).

Nonnegativity. On \([0,1]\), \(2x\geq 0\); elsewhere, \(f(x)=0\). Thus \(f\) is nonnegative everywhere.

Total integral. The function is zero outside \([0,1]\), so

$$ \int_{-\infty}^{\infty} f(x)\,dx =\int_0^1 2x\,dx =\left[x^2\right]_0^1 =1^2-0^2 =1. $$

Both checks pass, so \(f\) is a probability density. The requested probability is the integral over the interval:

$$ P\left(\frac14\leq X\leq\frac34\right) =\int_{1/4}^{3/4}2x\,dx =\left[x^2\right]_{1/4}^{3/4} =\left(\frac34\right)^2-\left(\frac14\right)^2 =\frac{9}{16}-\frac{1}{16} =\frac12. $$

The answer is a probability, so it lies between zero and one, as it should.

Calculating Interval Probabilities

For a single interval, the procedure is direct: identify the portion of the density relevant to that interval, integrate over its endpoints, and evaluate the integral. If the interval crosses a point where the formula changes, split the integral at that point and add the pieces. This follows from additivity of the integral over disjoint regions.

If \(f\) is given by different formulas on different ranges, it is helpful to draw or describe those ranges before calculating. In particular, do not integrate a formula beyond the range on which it was defined. Use the correct piece on each part of the requested interval.

Worked Example: An Interval Crossing Two Pieces

Let \(f(x)=1/4\) for \(0\leq x<2\), \(f(x)=1/2\) for \(2\leq x\leq 3\), and \(f(x)=0\) otherwise. Verify that \(f\) is a density and calculate \(P(1\leq X\leq 5/2)\).

Nonnegativity. Each specified value of \(f\) is nonnegative.

Total integral. The two nonzero pieces contribute

$$ \int_{-\infty}^{\infty} f(x)\,dx =\int_0^2 \frac14\,dx+\int_2^3 \frac12\,dx =\frac14(2-0)+\frac12(3-2) =\frac12+\frac12 =1. $$

Thus \(f\) is a probability density. The interval \([1,5/2]\) crosses the change at \(x=2\), so split it there:

$$ \begin{aligned} P\left(1\leq X\leq\frac52\right) &=\int_1^2\frac14\,dx+\int_2^{5/2}\frac12\,dx\\ &=\frac14(2-1)+\frac12\left(\frac52-2\right)\\ &=\frac14+\frac12\left(\frac12\right)\\ &=\frac14+\frac14 =\frac12. \end{aligned} $$

The first piece covers a length of one and contributes \(1/4\); the second covers a length of \(1/2\) and contributes \(1/4\). Their sum is the probability of the full interval.

Worked Example: Integrating Over an Unbounded Range

For \(x\geq 0\), let \(f(x)=(1/3)e^{-x/3}\), and let \(f(x)=0\) for \(x<0\). Check the density conditions and find \(P(1\leq X\leq 4)\).

Nonnegativity. The exponential function is positive, so \(f(x)>0\) for \(x\geq0\); for negative \(x\), \(f(x)=0\).

Total integral. The integral over the nonzero range is improper:

$$ \begin{aligned} \int_{-\infty}^{\infty}f(x)\,dx &=\lim_{M\to\infty}\int_0^M \frac13 e^{-x/3}\,dx\\ &=\lim_{M\to\infty}\left[-e^{-x/3}\right]_0^M\\ &=\lim_{M\to\infty}\left(1-e^{-M/3}\right) =1. \end{aligned} $$

Here \(e^{-M/3}\to0\), so the limit is one and \(f\) is a density. For the interval probability,

$$ \begin{aligned} P(1\leq X\leq4) &=\int_1^4\frac13e^{-x/3}\,dx\\ &=\left[-e^{-x/3}\right]_1^4\\ &=e^{-1/3}-e^{-4/3}\\ &\approx 0.7165-0.2636\\ &\approx 0.4529. \end{aligned} $$

The result is positive and less than one, consistent with an interval capturing only part of the total probability.

Why Endpoint Choices Do Not Change the Probability

For a density, including or excluding one interval endpoint does not affect the integral. The reason is that a single point has length zero. More generally, changing a density at a set of length zero does not change any of its integrals. The following result justifies the common interchange of open and closed endpoints in interval calculations.

Theorem: If \(X\) has density \(f\), then for every real number \(c\), \(P(X=c)=0\). Consequently, for \(a<b\), the probabilities of \((a,b)\), \([a,b]\), \([a,b)\), and \((a,b]\) are equal.

Proof. By the definition of a density, \(P(X=c)=\int_{\{c\}}f(x)\,dx\). The singleton \(\{c\}\) has length zero, so the integral of a nonnegative measurable function over this set is zero. Hence \(P(X=c)=0\). The difference between any two of the listed intervals consists only of one or both endpoints, whose probabilities are zero. Additivity of probability therefore gives the same probability for each interval. \(\square\)

This result is about probabilities under a density. It does not mean that the response cannot take a particular real value; it says that the probability assigned to any one exact value is zero. Interval probabilities, in contrast, can be positive because an interval has positive length and can accumulate positive integral.

A Reliable Calculation Routine

1
Check the domain and sign.
Identify where the formula applies, set the density to zero elsewhere if appropriate, and verify nonnegativity.
2
Check the total integral.
Integrate over every range where the density is nonzero. For an unbounded range, evaluate the required improper-integral limit.
3
Match the interval to the formula.
Split at any point where the density changes, and integrate the correct piece over each part.
4
Evaluate and check the result.
Add the contributions and confirm that the probability is between zero and one.

Common Mistakes

  • Stopping after checking nonnegativity. A nonnegative function is not automatically a density. Its integral over the full real line must also equal one.
  • Integrating a piecewise formula over the wrong range. If an interval crosses a boundary between formulas, split the integral at that boundary and use the appropriate formula on each piece.
  • Forgetting the zero-density region. Values outside the specified range contribute no probability. Do not extend a nonzero formula beyond its stated domain.
  • Reporting an interval integral larger than one without checking the setup. For a valid density, an interval probability cannot exceed the total integral of one. A result outside \([0,1]\) signals an arithmetic error or an invalid density.
Key takeaway: A continuous response model assigns probability to a set by integrating its density over that set. Verify nonnegativity and total integral one before using the density to calculate interval probabilities.

Check Your Understanding

Use the integration definition of a density to answer these questions.

  1. A function is nonnegative everywhere and has total integral \(0.8\). Can it be a probability density as given? Explain.
  2. For \(f(x)=3x^2\) on \(0\leq x\leq1\), with \(f(x)=0\) elsewhere, verify the density conditions and calculate \(P(0\leq X\leq1/2)\).
  3. A piecewise density changes formula at \(x=2\). What should you do if the requested interval extends from \(1\) to \(3\)?
  4. Why does a density assign probability zero to a single exact value?
  5. For a density on the nonnegative real line, what must be checked when its total integral is written as an integral from zero to infinity?
Clinical Biostats