Why Check a Density Before Using It?
A formula can look like a probability model and still fail to assign probabilities consistently. Before using a proposed density in a calculation, check two things: it must never be negative except possibly on a set of zero length, and its total area over the real line must be one. If the formula is proportional to a known nonnegative shape, the integral often determines the missing constant.
This tutorial focuses on those validity checks and on normalization. The examples use continuous random variables with candidate densities specified on a support and set to zero outside it. A candidate that fails either condition is not a probability density, so it cannot describe the stated model.
The Two Conditions and Their Meaning
The first condition is nonnegativity. A probability cannot be negative, so a function that assigns negative area to a region cannot represent probabilities there. For a piecewise formula, check the sign on each interval of its support, including any restrictions imposed by an unknown constant.
The second condition is unit total integral. The whole real line contains every possible value of \(X\), so the total probability assigned across that line must be one. If the density is zero outside a support \(S\), this condition can be written as \(\int_S f(x)\,dx=1\).
“Almost everywhere” allows a function’s value to be changed at isolated points, or on another set of length zero, without changing any of its integrals. In ordinary piecewise examples, it is simplest to check the formula throughout each interval and verify that its integral is one. The specified value at a shared endpoint does not affect the integral.
Why the Conditions Are Necessary and Sufficient
The conditions follow from the meaning of a density. If \(f\) is a density, taking the probability over all possible values gives the total integral:
Also, the integral over any measurable set must be a probability and therefore cannot be negative. If \(f\) were negative on a set of positive length, there would be some positive integer \(n\) for which the subset where \(f(x)\leq -1/n\) has positive length. The integral over that subset would be negative, contradicting that it represents a probability. Thus \(f\geq 0\) almost everywhere.
Conversely, suppose \(f\) is measurable, nonnegative almost everywhere, and has integral one. For each measurable set \(B\), the integral \(\int_B f(x)\,dx\) is nonnegative; the integral over the whole line is one; and integrals over disjoint sets add. These are the probability requirements for assigning probabilities by integration. The two checks are therefore not just useful shortcuts: together they establish that a candidate can serve as a density.
A Reliable Normalization Method
For a function with an unknown multiplicative constant, separate the sign check from the integration. If \(f(x)=c\,g(x)\) on its support, first determine which values of \(c\) make \(c\,g(x)\) nonnegative there. Then integrate each piece of \(g\), add the results, and set \(c\) times that total equal to one. Finally, check that the resulting \(c\) satisfies the sign condition.
Record where the formula applies and where the candidate is zero.
Determine the sign of each piece on its interval and note any restrictions on the constant.
Evaluate each integral over its stated interval, then add the results.
Set the total integral equal to one, solve for the constant, and check both conditions again.
Worked Normalization Examples
Worked Example: A Piecewise Density on Two Intervals
A hypothetical model proposes the density \(f_c(x)=cx\) for \(0\leq x<1\), \(f_c(x)=2c(2-x)\) for \(1\leq x\leq2\), and \(f_c(x)=0\) otherwise. Find \(c\), or explain why no valid value exists.
Method: check the shape, integrate each piece, and normalize. On the first interval, \(x\geq0\). On the second interval, \(2-x\geq0\). The shape is nonnegative on the support when \(c\geq0\). A density needs a positive total integral, so the normalizing value must in fact be positive.
The integral of the first piece is
The integral of the second piece is
Thus the total integral is \(c/2+c=3c/2\). Set it equal to one and solve:
Verification. The constant is positive, so both pieces remain nonnegative. The first piece contributes \(c/2=1/3\), and the second contributes \(c=2/3\); their sum is one. Therefore \(c=2/3\) gives a valid density. A common mistake this method avoids is dropping the factor \(2\) in the second piece, which would give the wrong total area.
Worked Example: Normalizing a Polynomial Density
For a hypothetical continuous measurement \(X\), consider \(f_c(x)=cx(2-x)\) on \(0\leq x\leq2\), with \(f_c(x)=0\) elsewhere. Determine the normalizing constant.
Method: establish the sign of the polynomial, then integrate. On \([0,2]\), both \(x\) and \(2-x\) are nonnegative, so \(x(2-x)\geq0\). The density condition requires \(c\geq0\), and normalization will require \(c>0\).
Expand the polynomial and integrate across the support:
At the upper endpoint, \(x^2-x^3/3=4-8/3=4/3\); at the lower endpoint it is zero. Therefore the total integral is \(4c/3\), and
Verification. Since \(c=3/4>0\) and the polynomial shape is nonnegative over the support, the candidate is nonnegative. Substitution gives total integral \((3/4)(4/3)=1\). The common mistake avoided here is assuming that a polynomial is nonnegative merely because its endpoints are nonnegative; the sign must be checked throughout the support.
Worked Example: A Three-Part Piecewise Shape
A hypothetical model assigns a density proportional to \(x\) on \(0\leq x<1\), to \(2\) on \(1\leq x<2\), and to \(3-x\) on \(2\leq x\leq3\). It is zero elsewhere. Find the proportionality constant \(c\), and check validity.
Method: add the areas of all three pieces before solving for \(c\). Each unscaled piece is nonnegative on its interval: \(x\geq0\), the middle shape is \(2\), and \(3-x\geq0\). Hence \(c\) must be nonnegative.
The unscaled areas are
Their sum is \(1/2+2+1/2=3\). Thus the total integral of the proposed density is \(3c\), and normalization gives
Verification. The constant is positive, so every piece is nonnegative. The three scaled areas are \(1/6\), \(2/3\), and \(1/6\), which sum to one. Therefore \(c=1/3\) is valid. The common mistake avoided is integrating only the first and last pieces and overlooking the full middle interval.
Common Mistakes and Exam Traps
Normalization is an integration problem, but it is also a modeling check. A correctly evaluated integral does not by itself prove that a candidate is a density: the sign condition must also hold. Conversely, a nonnegative function is not automatically a density if its total integral is not one.
- Forgetting a piece or a multiplier. In the first example, the second piece includes a factor of \(2\). Omitting it changes its area from \(c\) to \(c/2\), so it changes the constant.
- Ignoring the support. Integrate over the intervals where the formula applies. If the function is zero elsewhere, those other regions add no area.
- Solving the integral equation but skipping the sign check. An equation may produce a constant that makes a piece negative. Such a solution is not a valid density.
- Assuming any constant repairs a negative shape. Multiplication by a positive constant preserves the shape’s signs; multiplication by a negative constant reverses all of them. Neither choice can make a shape with both positive and negative regions nonnegative everywhere.
- Using the wrong interval endpoints in integration. For a piecewise function, use the bounds specified for each piece and account for every interval exactly once.
For instance, \(g(x)=x-1\) on \([0,2]\) is negative on \([0,1)\) and positive on \((1,2]\). No nonzero multiplier can make \(c\,g(x)\) nonnegative on both intervals: a positive \(c\) leaves the first interval negative, while a negative \(c\) makes the second interval negative. This sign failure should be noticed before attempting normalization.
Check Your Understanding
For each candidate, check its sign as well as its total integral before deciding whether it defines a density.
- A candidate is \(f_k(x)=k(1+x)\) for \(0\leq x\leq1\) and zero elsewhere. Find the value of \(k\) that makes it a density. (Answer: \(k=2/3\).)
- A candidate is \(f_c(x)=c(4-x)\) for \(1\leq x\leq3\) and zero elsewhere. Find \(c\) and verify the sign condition. (Answer: \(c=1/4\).)
- A candidate is \(f_c(x)=cx\) for \(0\leq x<2\), \(f_c(x)=c(4-x)\) for \(2\leq x\leq4\), and zero elsewhere. Find \(c\). (Answer: \(c=1/4\).)
- Can \(f_c(x)=c(x-1)\) on \(0\leq x\leq2\), and zero elsewhere, be a density for any real \(c\)? Use both the sign and integral conditions. (Answer: No; its shape changes sign, and its integral is zero for every \(c\).)
- A candidate is \(f_c(x)=c(1-x)\) for \(0\leq x<1\), \(f_c(x)=c(x-1)\) for \(1\leq x\leq2\), and zero elsewhere. Find \(c\) and verify the total area. (Answer: \(c=1\); the two pieces each contribute \(1/2\).)