St · Statistics & Probability

How to Find a Probability Density Function (PDF)

Published By the 9to5Science editorial team

At a glance

  1. 1. Identify what is given

    Use the distribution, cumulative distribution function, or transformation rule that describes the random variable.

  2. 2. Choose a method

    Differentiate a CDF, use a known distribution, or apply the change-of-variables formula.

  3. 3. Determine the support

    Find the values the random variable can take, and set the density to zero elsewhere.

  4. 4. Check the result

    Verify the density is nonnegative and integrates to one over its support.

A probability density function (PDF) describes an absolutely continuous distribution of a random variable. The method for finding one depends on what information you have: a cumulative distribution function (CDF), a formula for the random variable, or a named distribution. Without some such information, there is no unique PDF to find.

What a probability density function tells you

For a random variable XX with a PDF fX(x)f_X(x), the density is nonnegative and gives probabilities by integration:

P(a≤X≤b)=∫abfX(x) dx.P(a \leq X \leq b)=\int_a^b f_X(x)\,dx.

The total probability must be one:

∫−∞∞fX(x) dx=1.\int_{-\infty}^{\infty} f_X(x)\,dx=1.

A density value is not itself a probability. In particular, for a variable with a PDF, P(X=x)=0P(X=x)=0 for any single value xx, even if fX(x)f_X(x) is positive. Probabilities come from areas under the density curve.

Method 1: Differentiate the CDF

If you know the CDF FX(x)=P(X≤x)F_X(x)=P(X\leq x) and the distribution is absolutely continuous (so it has a PDF), then its PDF is the derivative of the CDF almost everywhere:

fX(x)=ddxFX(x).f_X(x)=\frac{d}{dx}F_X(x).

First identify the intervals on which the CDF changes, differentiate on those intervals, and set the density to zero outside the range of possible values. A CDF can have corners where its derivative is undefined; that does not prevent the random variable from having a density. For an absolutely continuous distribution, the derivative formula applies almost everywhere. But differentiating a CDF does not recover discrete or singular components of a distribution.

Worked example: the square of a uniform variable

Suppose XX is uniform on [0,1][0,1], and define Y=X2Y=X^2. Since 0≤X≤10\leq X\leq1, the possible values of YY are also in [0,1][0,1].

For 0≤y≤10\leq y\leq1,

FY(y)=P(Y≤y)=P(X2≤y)=P(X≤y)=y.\begin{aligned} F_Y(y)&=P(Y\leq y)\\ &=P(X^2\leq y)\\ &=P(X\leq\sqrt{y})\\ &=\sqrt{y}. \end{aligned}

Including the parts outside the support, the CDF is 00 for y<0y<0, y\sqrt{y} for 0≤y≤10\leq y\leq1, and 11 for y>1y>1. Differentiate on the interior of the support:

fY(y)={12y,0<y<1,0,otherwise.f_Y(y)=\begin{cases} \dfrac{1}{2\sqrt{y}},&0<y<1,\\ 0,&\text{otherwise.} \end{cases}

The density becomes unbounded as yy approaches zero, but it is still valid: the singularity is integrable, and ∫0112y dy=1\int_0^1 \frac{1}{2\sqrt{y}}\,dy=1. The value assigned at a single endpoint does not change any probabilities.

Method 2: Transform a known density

If Y=g(X)Y=g(X) and gg is one-to-one and differentiable on the support of XX, use the change-of-variables formula. Write x=g−1(y)x=g^{-1}(y), then

fY(y)=fX(g−1(y))∣ddyg−1(y)∣,f_Y(y)=f_X\bigl(g^{-1}(y)\bigr)\left|\frac{d}{dy}g^{-1}(y)\right|,

for values of yy in the transformed support; set it to zero elsewhere. The absolute value accounts for whether the transformation increases or decreases.

If gg is not one-to-one, include every solution xix_i to g(xi)=yg(x_i)=y that lies in the support of XX:

fY(y)=∑ifX(xi)∣g′(xi)∣.f_Y(y)=\sum_i \frac{f_X(x_i)}{|g'(x_i)|}.

This formula assumes the relevant branches are differentiable and that the derivative is nonzero at the inverse points. When a transformation has endpoints or stationary points where this fails, derive the CDF directly or handle those points separately.

For the worked example, the inverse on [0,1][0,1] is x=yx=\sqrt{y}, and dx/dy=1/(2y)dx/dy=1/(2\sqrt{y}). Since fX(x)=1f_X(x)=1 on [0,1][0,1], the transformation formula gives the same density, fY(y)=1/(2y)f_Y(y)=1/(2\sqrt{y}) for 0<y<10<y<1.

Method 3: Recognize a named distribution

Sometimes the PDF is already known once you identify the model and its parameters. For example, a normal random variable with mean μ\mu and standard deviation σ>0\sigma>0 has density

fX(x)=1σ2πexp⁡(−(x−μ)22σ2),−∞<x<∞.f_X(x)=\frac{1}{\sigma\sqrt{2\pi}}\exp\left(-\frac{(x-\mu)^2}{2\sigma^2}\right),\qquad -\infty<x<\infty.

Check the parameter convention: some distributions are written using variance rather than standard deviation, or use a rate parameter where another source uses a scale parameter. If the random variable is a sum or another function of random variables, you may need a convolution, a transformation, or a CDF calculation rather than a standard named formula.

Common mistakes

  • Treating a density value as a probability. To find an interval probability, integrate the density over that interval.
  • Forgetting the support. A formula may only apply on a specific interval; the density is zero outside it unless the model says otherwise.
  • Omitting the derivative factor. When transforming a variable, the inverse derivative (or its absolute value) is essential.
  • Using only one inverse branch. For a many-to-one transformation such as Y=X2Y=X^2 when XX can be positive or negative, contributions from both roots must be included.
  • Assuming every random variable has a PDF. Discrete variables have probability mass functions. Some distributions combine point masses with a continuous density, and singular continuous distributions also exist, so their entire probability cannot be represented by an ordinary PDF alone.

After finding a candidate PDF, check that it is nonnegative on its support and that its integral over the full support is one. If either check fails, revisit the differentiation, transformation, or support.

References

  1. A First Course in Probability — Sheldon Ross
  2. Statistical Inference — George Casella and Roger L. Berger

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.