4.1 - Piecewise probability densities

4.1 - Piecewise probability densities

A probability density can change formula, jump, or even rise above one. In this lesson you will decide whether a piecewise function is a valid density, calculate probabilities across its pieces, and find expectations and variances of functions of a continuous random variable.

A valid density

Can a probability density be taller than one without giving an impossible probability? Yes: a density gives probability through area, rather than through its height at one point.

You already know from continuous distributions that an interval probability is an integral. For example, a rectangle of width 1/21/2 and height 22 has area 11. Its height exceeds one, but it can describe a distribution concentrated in a short interval.

Probability density function

A probability density function, or PDF, for a continuous random variable XX is a nonnegative function ff with total area one:

f(x)≥0,∫−∞∞f(x) dx=1.f(x)\ge0, \qquad \int_{-\infty}^{\infty}f(x)\,\mathrm dx=1.

Then P(a<X<b)=∫abf(x) dx\mathrm P(a<X<b)=\int_a^b f(x)\,\mathrm dx. The support identifies where the distribution can take values; give the intervals and state that the density is zero elsewhere.

A piecewise definition tells you which expression to use on each interval. Check nonnegativity on every piece, then add their areas. The formulae need not join at the same height: a density may have a jump.

Worked example 1: normalising two pieces

Question. Find kk so that the following is a PDF:

f(x)={kx0≤x≤1k1<x≤30otherwise.f(x)= \begin{cases} kx&0\le x\le1\\ k&1<x\le3\\ 0&\text{otherwise}. \end{cases}

Plan. Integrate each nonzero piece, make their sum one, then check the sign.

1=∫01kx dx+∫13k dx=k2+2k=5k2k=25.\begin{aligned} 1&=\int_0^1 kx\,\mathrm dx+\int_1^3 k\,\mathrm dx\\ &=\frac{k}{2}+2k=\frac{5k}{2}\\ k&=\frac25. \end{aligned}

Both xx on the first interval and the constant on the second interval are nonnegative when k=2/5k=2/5.

Answer. k=2/5k=2/5, giving a valid density on [0,3][0,3].

Check. Geometry gives a triangle of area 12(1)(2/5)=1/5\tfrac12(1)(2/5)=1/5 and a rectangle of area 2(2/5)=4/52(2/5)=4/5. Their total is one.

The next density retains a rising first piece but replaces the finite second piece by a decreasing tail. An infinite support does not require an infinite area.

Worked example 2: an unbounded support

Question. Find kk so that

f(x)={kx0≤x≤1kx−5x>10x<0f(x)= \begin{cases} kx&0\le x\le1\\ kx^{-5}&x>1\\ 0&x<0 \end{cases}

is a PDF.

Plan. Use an improper integral for the tail and check nonnegativity.

∫1∞kx−5 dx=lim⁡b→∞[−k4x4]1b=k41=k2+k4=3k4k=43.\begin{aligned} \int_1^\infty kx^{-5}\,\mathrm dx &=\lim_{b\to\infty}\left[-\frac{k}{4x^4}\right]_1^b =\frac{k}{4}\\ 1&=\frac{k}{2}+\frac{k}{4}=\frac{3k}{4}\\ k&=\frac43. \end{aligned}

Both nonzero expressions are nonnegative for this value of kk.

Answer. k=4/3k=4/3, with support [0,∞)[0,\infty).

Check. Substituting u=1/xu=1/x gives the tail area as 43∫01u3 du=1/3\tfrac43\int_0^1u^3\,\mathrm du=1/3. The first piece is a triangle of area 2/32/3, confirming total one by a different calculation. The maximum density is 4/34/3; a height above one causes no problem.

Total signed integral one is insufficient if some of the curve lies below the axis. For example, the function 2x2x on [0,1][0,1], 2(2−x)2(2-x) on (1,3](1,3], and zero elsewhere has integral one, but is negative for 2<x≤32<x\le3. It cannot be a PDF.

Watch out

Do not check only ∫f(x) dx=1\int f(x)\,\mathrm dx=1. A negative piece would assign a negative probability to some interval. Check both nonnegativity and total area.

Apply both conditions to a new pair of pieces.

Intervals across pieces

A probability interval may cross a point where the density changes formula, so split the integral at every such point inside the interval.

Return to the density from Worked example 1:

f(x)={25x0≤x≤1251<x≤30otherwise.f(x)= \begin{cases} \frac25x&0\le x\le1\\ \frac25&1<x\le3\\ 0&\text{otherwise}. \end{cases}

The shaded area in the diagram crosses x=1x=1. Its two parts need different integrands.

[DIAGRAM: asset_name: An interval crossing two density pieces; asset_slug: cam9231-piecewise-area; caption: Split the shaded probability at x equals 1, where the density changes formula; description: Exact PDF f(x) equals two fifths x on zero to one and two fifths on one to three, with zero elsewhere. Pale blue shading from one half to one has area three twentieths; pale lavender shading from one to two has area two fifths. Dashed guides mark one half, one and two, and the total shaded probability is eleven twentieths.]
Split the shaded probability at x equals 1, where the density changes formula

For any single value aa, the integral from aa to itself is zero. Thus P(X=a)=0\mathrm P(X=a)=0, and including or excluding individual endpoints does not change an interval probability. Changing a density's value at an isolated endpoint also leaves all its probabilities unchanged.

Worked example 3: staying inside one piece

Question. For this density, find P(1/4<X<3/4)\mathrm P(1/4<X<3/4).

Plan. Both limits lie below one, so use only the rising piece.

P(14<X<34)=∫1/43/425x dx=[x25]1/43/4=15(916−116)=110.\begin{aligned} \mathrm P\left(\frac14<X<\frac34\right) &=\int_{1/4}^{3/4}\frac25x\,\mathrm dx\\ &=\left[\frac{x^2}{5}\right]_{1/4}^{3/4}\\ &=\frac15\left(\frac9{16}-\frac1{16}\right)=\frac1{10}. \end{aligned}

Answer. P(1/4<X<3/4)=1/10\mathrm P(1/4<X<3/4)=1/10.

Check. The region is a trapezium of width 1/21/2, with parallel sides 1/101/10 and 3/103/10. Its area is 12(1/2)(1/10+3/10)=1/10\tfrac12(1/2)(1/10+3/10)=1/10.

Now change the interval so that its upper end lies in the constant piece. The probability is the sum of two areas, not one formula evaluated across the whole interval.

Continue this lesson.

You’re previewing NovaLearn without an account. Create a free account to read the rest.

Create free account