A probability density function f(x) describes a continuous random variable. The probability that X lands between a and b is the area under f from a to b. A valid density is never negative, and the total area under it is 1.
The height of the curve is a density, not a probability. It is probability per unit of x, so it can exceed 1: a uniform distribution on [0, 0.5] has density 2 across that interval, and the area is still 0.5 × 2 = 1. Change the units and the heights change with them. A normal distribution of adult heights with a standard deviation of 7 cm peaks at a density of 0.057 per centimetre, which is 5.7 per metre. Only areas are probabilities.
The probability of any exact value is 0, because a single point has no width. So P(X ≤ b) and P(X < b) are the same number for a continuous variable, and every question is about a range.
The cumulative distribution function (CDF) is the running area: F(x) = P(X ≤ x), the integral of the density from −∞ up to x. It climbs from 0 to 1 and never decreases. The density is its derivative, f(x) = F′(x), so the PDF is tall where the CDF rises fastest. Any range needs two CDF values: P(a < X ≤ b) = F(b) − F(a). Run the CDF backwards and you get the quantile function: F⁻¹(0.9) is the 90th percentile.
Example: exam scores follow a normal distribution with mean 70 and standard deviation 10. The density at 70 is 1 / (10 × √(2π)) = 0.0399 per point, which is not the chance of scoring exactly 70. The share scoring between 60 and 85 is F(85) − F(60) = 0.9332 − 0.1587 = 0.7745, and the score that beats 90% of the class is F⁻¹(0.9) = 82.8. For a standard normal, F(1.96) − F(−1.96) = 0.95, which is where the 1.96 in a 95% confidence interval comes from.
One you can integrate by hand: the wait for the next event at a steady rate is exponential, f(x) = λe^(−λx) for x ≥ 0. With an average wait of 5 minutes, λ = 0.2 per minute. The CDF is F(x) = 1 − e^(−λx), so P(X > 10) = e^(−2) = 0.135 and P(2 < X < 5) = e^(−0.4) − e^(−1) = 0.670 − 0.368 = 0.302.
Discrete variables have a probability mass function (PMF) instead. Each value has a real probability, the probabilities sum to 1, and none can exceed 1. The binomial distribution has a PMF and the normal has a PDF. Both have a CDF; a discrete one climbs in steps. Some variables mix the two: revenue per user has a lump of probability at exactly 0 and a density over the positive amounts.
Means and variances are integrals against the density: E[X] = ∫ x f(x) dx and Var(X) = ∫ (x − μ)² f(x) dx. For the exponential example the first integral gives 1/λ = 5 minutes. Two variables have a joint density f(x, y). Integrating one variable out leaves the marginal of the other, and the conditional density is f(x | y) = f(x, y) / f(y), so Bayes' theorem works with densities in place of probabilities.
In machine learning, the likelihood of continuous data is the product of the density at each observation, read as a function of the parameters, and maximum likelihood picks the parameters that make it largest. Because densities are not probabilities, a likelihood can exceed 1 and a log-likelihood can be positive. Histograms and kernel density estimation estimate a density from samples. On a histogram's density scale a bar's height is count / (n × bin width), which is why bars can rise above 1. A kernel density estimate has a bandwidth that trades smoothness against detail.
In code: scipy.stats.norm.pdf(x, mu, sigma) is the density, .cdf the area to the left, .sf the area to the right and .ppf the inverse CDF. In R, dnorm is the density, pnorm the CDF and qnorm its inverse. On a TI-84, normalpdf is the height of the curve and normalcdf is an area, so probabilities come from normalcdf.
Interview follow-ups: why P(X = x) is 0 when some value always occurs; how to check that a function is a valid density (never negative, integrates to 1); how a density changes under a transformation, f_Y(y) = f_X(x) × |dx/dy|, the rule behind normalizing flows; and how to sample from any distribution by feeding uniform random numbers through the inverse CDF (inverse transform sampling).