# How can a probability density be greater than one and integrate to one

Wikipedia says:

The probability density function is nonnegative everywhere, and its integral over the entire space is equal to one.

and it also says.

Unlike a probability, a probability density function can take on values greater than one; for example, the uniform distribution on the interval $[0, \frac{1}{2}]$ has probability density $f(x) = 2$ for $0 ≤ x ≤ \frac{1}{2}$ and $f(x) = 0$ elsewhere.

How are these two things compatible?

Consider the uniform distribution on the interval from $0$ to $1/2$. The value of the density is $2$ on that interval, and $0$ elsewhere. The area under the graph is the area of a rectangle. The length of the base is $1/2$, and the height is $2$
$$\int\text{density} = \text{area of rectangle} = \text{base} \cdot\text{height} = \frac 12\cdot 2 = 1.$$
More generally, if the density has a large value over a small region, then the probability is comparable to the value times the size of the region. (I say “comparable to” rather than “equal to” because the value my not be the same at all points in the region.) The probability within the region must not exceed $1$. A large number—much larger than $1$—multiplied by a small number (the size of the region) can be less than $1$ if the latter number is small enough.