A clock stops at a random moment during the day. What is the chance that it stopped at exactly 10:00:00? The answer is zero. It sounds odd, but it is true, and it is the key to understanding the probability density function. Time is continuous, so there are endless possible moments, and each single moment has no probability of its own.
What you can ask is the chance that the clock stopped between 6 and 9 o’clock. That is a real, non zero probability, and the probability density function is the tool that gives it to you. It describes how probability is spread over a continuous range, such as time, height, weight, rainfall or waiting time.
This tutorial explains what a PDF is, the two rules it must follow, the formula, how to read it as an area, two worked examples with all the numbers, how it differs from the CDF and the PMF, and how to calculate it in Python.
A probability density function, or PDF, describes the distribution of a continuous random variable. A continuous variable can take any value in a range, such as 1.7 or 1.7001 metres. This is different from a discrete variable, such as the number on a die, which takes separate values.
The PDF is a function, f(x), whose curve shows where the values are most concentrated. A high curve means that values near there are more likely. A low curve means that they are less likely.

The live page calls the PDF the relative likelihood of a given value. That is close, but it hides an important point. The height of the curve at x is a density, not a probability. It can even be bigger than 1. For example, a variable spread evenly between 0 and 0.5 has a density of 2 everywhere. The area is 2 times 0.5 = 1, which is what must hold.
For a continuous variable, you cannot list the probability of every value, because there are infinitely many. The PDF lets you find the probability of any range.

The live page gives the example of the chance of rain in July, using past data that shows rainfall between limits a and b. It says that the aim is to find the nearest exact value. That is not the idea. The aim is to find the probability that rainfall falls in a range, and this is the area under the PDF between the two limits.
The live page also says that PDFs measure the risk of a stock or ETF. In finance, a PDF can model returns, but it is a general tool for any continuous variable, and this page is not investment advice.

The probability that X lies between a and b is the area under the PDF between a and b:
In words: the probability of a range is the area under the curve over that range. The total area is 1, and the probability of any single exact value is 0, because a single point has no width.
The live page shows the formula only as an image. Here are the most common PDFs in text:
| Distribution | PDF f(x) | Where it applies |
|---|---|---|
| Uniform from a to b | 1 divided by (b minus a) | a is at most x, and x is at most b |
| Normal with mean mu and standard deviation sigma | (1 divided by (sigma times the square root of 2 times pi)) times e to the power of minus (x minus mu) squared divided by (2 times sigma squared) | All x |
| Exponential with rate r | r times e to the power minus r times x | x is 0 or more |

The live page: a clock stops at a random time during the day, and the time of stopping is x. The PDF is shown only in an image. If every moment of the day is equally likely, the PDF is uniform on 0 to 24 hours.
Meaning: a three hour window has a one in eight chance. A single instant has none, and the chance for a tiny window grows with its width. The value 0.0417 is a density, in probability per hour, and not a probability.
The live page describes the rain example without numbers. Here is a version with made up numbers. Suppose July rainfall in a city is normal, with a mean of 200 mm and a standard deviation of 50 mm.
| Question | Answer | How |
|---|---|---|
| Density at 200 mm | 0.00798 | The height of the curve at the peak |
| Chance of rain between 150 and 250 mm | 0.6827 | The area within 1 standard deviation |
| Chance of more than 300 mm | 0.0228 | The right tail beyond 2 standard deviations |
| Chance of exactly 200 mm | 0 | A single point has no area |
| Chance between 199 and 201 mm | 0.016 | A narrow strip around the peak |
I checked the area between 150 and 250 mm in two ways: by integrating the PDF, 0.6827, and by simulating 100,000 months, 0.6812. They agree.
| Point | CDF | PMF | |
|---|---|---|---|
| For | Continuous variables | Continuous or discrete | Discrete variables |
| Gives | Density at x | P(X at most x) | P(X = x) |
| Probability of one value | 0 | Not applicable | Can be above 0 |
| Probability of a range | Area under the curve | CDF at b minus CDF at a | Sum of the PMF |
| Total | Area is 1 | Rises from 0 to 1 | Sum is 1 |
The CDF is the running total of the PDF. For the standard normal curve, the PDF at 0 is 0.3989, and the CDF at 1.96 is 0.975, which is the area to the left of 1.96.
I ran the code below, and the output is real.
| Mistake | Fix |
|---|---|
| Treating the PDF value as a probability | It is a density. Probability is an area |
| Asking for the probability of one exact value | It is 0. Ask for a range |
| Expecting the density to be at most 1 | It can exceed 1. The area must be 1 |
| Forgetting the total area is 1 | Check that your function integrates to 1 |
| Using a PDF for a discrete variable | Use the PMF |
| Mixing the PDF and the CDF | The CDF is the area up to x |
| Using a negative function | A PDF is never negative |
| Treating a PDF as investment advice | It is a general tool for modelling |
Answers: 1) f(x) = 1 divided by 10 = 0.1, and the chance is 3 times 0.1 = 0.3. 2) 0. 3) 1 divided by 0.25 = 4. 4) It is never negative, and the total area under it is 1. These are my own answers, so please recheck them before publishing.
A probability density function is a map of where a continuous variable is likely to fall. Read it as an area, not as a height: the height is a density, and the area over a range is the probability. Remember that, and everything from the normal curve to a confidence interval becomes clearer.