Probability density function in this visualization
A probability density function describes a continuous random variable through areas: , where and the total area is 1. Here the line is cut into bins of width , and each bar is a bin’s exact probability, either as it is or divided by , drawn over ; below it is the cumulative distribution function . With the bars as densities, halving brings them onto ; there are five distributions to try, one of them drawn by hand.
What does the height measure? Probability per unit length, not probability. A bin’s probability divided by its width is the average of over the bin, so where is continuous at , the bar around tends to as shrinks, and a short interval has . That is why a density can exceed 1 even though no probability does: probability is the area, and a tall, narrow region can have a small area. A single point is an interval of width 0, so whatever is, and for such a variable and give the same probabilities.
How do the density and the cumulative distribution function fit together? is the area under to the left of , so the area over above is the rise below. A bin’s probability is the rise of across the bin, so the bar divided by is the slope of the secant of over that bin. As shrinks, the secant turns toward the tangent: where is continuous, , which is the fundamental theorem of calculus. Where jumps, as at the ends of the uniform, has a corner, and its slopes from the two sides are the values of on the two sides. Changing at a single point changes no area, so no probability changes either.
Why is a histogram divided by its bin width before it is compared with a density? Without the division the bars are probabilities, and they sink toward 0 as the bins narrow, not toward . Divided by , the bars over the whole line have total area 1 whatever the width, so histograms with different bins can be compared with each other and laid over . A histogram of data works the same way, with each bin’s share of the sample in place of its exact probability.
Things to notice
- The largest bin probability in the record sinks toward 0, but no probability is lost: the bins multiply as they narrow, and their total stays the same.
- The bins start at 0, so from on their ends fall on every jump of these densities. A bin across a jump would mix the two sides, and the largest deviation would stay at least half the jump however small became.
Controls
- Press either layer to choose the point whose bin is selected and where the tangent touches; drag a ▲ handle to set the interval, and drag past the left edge for .
- With Draw chosen and the bars showing density, draw on the upper layer: the curve is scaled to area 1.