Both dpois and dnorm in the code below sum to 1 (or thereabouts). This appears to confirm my understanding of the dpois and dnorm functions, which is that they represent proportions.

sum(dpois(x = 0:20, lambda = 5))
# 1

sum(dnorm(-10:30, mean = 10, sd = 2, log = FALSE))
# 1

But the output of dbeta does not sum to 1. Why is this?

sum(dbeta(c(0.1, 0.2, 0.3), shape1 = 2, shape2 = 4, ncp = 0, log = FALSE))
# 5.564

3 Answers 3


The relevant property of a probability density is not that it sums (for evaluation on some particular $x$ values) to one, but that it integrates to one.

If you evaluate a density $f$ at $x$ values that form a regular grid with grid width $\Delta x$, then you have very approximately

$$ \int_{-\infty}^\infty f(x)\,dx \approx \sum_{i=1}^n f(x_i)\Delta x, $$

which is why your initial two examples sum to almost one: here we have $\Delta x=1$, so we have approximately

$$ 1=\int_{-\infty}^\infty f(x)\,dx \approx \sum_{i=1}^n f(x_i). $$

Compare a finer grid for the normal case:

> sum(dnorm(seq(-10,30,by=0.1), mean = 10, sd = 2, log = FALSE))
[1] 10

And of course, if we include $\Delta x$ in your calculation for dbeta, then we again approximate the integral correctly:

> xx <- seq(0,1,by=0.01)
> sum(dbeta(xx, shape1 = 2, shape2 = 4, ncp = 0, log = FALSE)*mean(diff(xx)))
[1] 0.9998333
  • 1
    $\begingroup$ stats.stackexchange.com/a/133370/22228 For a very similar - but not quite duplicate - question, about why the area under a PDF equalled one, I produced a graph for pretty much exactly the equations you wrote (including the approximation with rectangles) and it even uses a beta distribution! Feel free to steal one of the pics - in fact the ggplot code for the plots probably still works so might not even be too much work to customise it for the given beta distribution $\endgroup$
    – Silverfish
    Commented May 6, 2023 at 20:46

dpois is the probability mass function (pmf) a discrete Poisson distribution that can take integer values in $(0, \infty)$. If you sum over the probabilities for all integers, you should indeed get 1.

dnorm is the probability density function (pdf) for the normal distribution over the real numbers in $(\infty, \infty)$ and dbeta the pdf for a Beta distribution over $(0, 1)$. These will sum to 1, if you integrate them over their domain.

pdfs are the continuous distribution equivalent to pmfs, but that sum(dnorm(-10:30, mean = 10, sd = 2, log = FALSE)) sums to 1 is pure coincidence (or someone giving you a trick question).

  • 1
    $\begingroup$ For your third paragraph: that this sums to one is not a coincidence, but the rectangle rule for integral approximation, with a rectangle width that just happens to be one because of the particular grid. $\endgroup$ Commented May 5, 2023 at 6:33
  • $\begingroup$ Yes, in a sense, but it wouldn't be true if the sd had been 100, or if mean had been 13,712. Someone carefully chose the grid points and was careful to space them 1.0 apart to avoid the need for a scaling constant. $\endgroup$
    – Björn
    Commented May 5, 2023 at 17:40
  • $\begingroup$ The sum of the normal density at integer points being extremely close to $1$ (though not exact) is not a coincidence. It is a result of the sum over all integers being $\vartheta_3\left(\pi \mu, e^{-2\pi \sigma^2}\right)$, at least in the Mathematica/Mathworld notation for Jacobi theta functions, and this being close to $1$ for $\sigma^2>1$. The exact limit being $1$ as the variance increases is not a surprise either: it is an increasingly good rectangular approximation to the integral. $\endgroup$
    – Henry
    Commented May 6, 2023 at 23:55
  • $\begingroup$ sum(dnorm(0:20000, mean = 13712, sd = 100, log = FALSE)) gives 1 at least up to rounding (the range for the integers needs to cover the values where the density is of a noticeable size). Try sum(dnorm(-200:200,mean=0,sd=0.1,log=FALSE)) giving 3.989423 and sum(dnorm(-200:200,mean=0.5,sd=0.1,log=FALSE)) giving 0.0000297 for better counterexamples $\endgroup$
    – Henry
    Commented May 7, 2023 at 0:17

d* functions represent proportions only with a discrete response. In fact, your dnorm example just happens to sum to one, but

> sum(dnorm(seq(-10, 30, by = 0.01), mean = 10, sd = 2, log = FALSE))
[1] 100

is 100! The normal and beta distributions are continuous, not discrete. Therefore, instead of summing to 1, they must integrate to 1, which is different.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.