# Unclear piece of the documentation to BinomialDistribution

Looking in the documentation , I read

The probability density and cumulative distribution functions may be given using PDF[BinomialDistribution[n,p],x] and CDF[BinomialDistribution[n,p],x]. The mean, median, variance, raw moments, and central moments may be computed using Mean, Median, Variance, Moment, and CentralMoment, respectively. These quantities can be visualized using DiscretePlot

and see an example

pdf=PDF[BinomialDistribution[n, p], k]


Piecewise[{{(1 - p)^(-k + n)*p^k*Binomial[n, k], 0 <= k <= n}}, 0]

But this does not possess usual properties of a PDF. For example,

n = 5; p = 1/3; NIntegrate[pdf, {k, -Infinity, Infinity}]


0.950953

and such a definition causes many bugs. Here is one of these.

 ClearAll[n, p, x, y, n]; pdf =  PDF[TransformedDistribution[ Max[x, y/n],
{Distributed[x, UniformDistribution[{0, 1}]], Distributed[y, BinomialDistribution[n, p]]}], t];
FullSimplify[pdf, Assumptions -> n \[Element] PositiveIntegers && 0 < p && p < 1 && t \[Element] Reals]


Piecewise[{{1 - (1 - p)^(-1 + n - Floor[n*t])*p^(1 + Floor[n*t])*Binomial[n, 1 + Floor[n*t]]* Hypergeometric2F1[1, 1 - n + Floor[n*t], 2 + Floor[n*t], p/(-1 + p)], Inequality[0, Less, t, LessEqual, 1] && n*t > Floor[n*t]}, {0, (t < 0 || t > 1) && n*t > Floor[n*t]}},Indeterminate]

n = 5; p = 1/3; NIntegrate[Piecewise[{{1 - (1 - p)^(-1 + n - Floor[n*t])*p^(1 + Floor[n*t])*
Binomial[n, 1 + Floor[n*t]]*Hypergeometric2F1[1, 1 - n + Floor[n*t], 2 + Floor[n*t],
p/(-1 + p)], Inequality[0, Less, t, LessEqual, 1] && n*t > Floor[n*t]}, {0, (t < 0 || t > 1) &&
n*t > Floor[n*t]}},Indeterminate], {t, -Infinity, Infinity}]


0.666662

The same issues with other discrete distributions and dozens of bugs may be presented in this field.

The question arises: is the quoted documentation correct or I don't understand something?

For discrete distributions use Sum:

Sum[PDF[BinomialDistribution[n, p], k], {k, -\[Infinity], \[Infinity]}]

(* Piecewise[{{1, n >= 0}}, 0] *)

• Thank you for your interest to the question. I am out of MMA at the moment so I'll give my response later . Nov 23, 2022 at 13:03
• It's honestly a bit unfortunate that in WL the function PDF is used for proper PDFs but also for PMFs. Those are definitely not the same thing. Nov 23, 2022 at 14:41
• Unfortunately, n = 5; p = 1/3; NSum[ Piecewise[{{1 - (1 - p)^(-1 + n - Floor[n*t])*p^(1 + Floor[n*t])* Binomial[n, 1 + Floor[n*t]]* Hypergeometric2F1[1, 1 - n + Floor[n*t], 2 + Floor[n*t], p/(-1 + p)], Inequality[0, Less, t, LessEqual, 1] && n*t > Floor[n*t]}, {0, (t < 0 || t > 1) && n*t > Floor[n*t]}}, Indeterminate], {t, -Infinity, Infinity}] fails as well as Sum. Also such an approach is not documented. Conclusion -- this is not it. Thank you anyway. I wonder the upvoters. Nov 23, 2022 at 15:51
• No need to get defensive. Of course it's a bug. I'm just saying to use CDF for situations like these since it's more likely to give the right result. Nov 23, 2022 at 17:33
• @user64494 You've commented (maybe more than once) that "The PDF exists only for absolutely continuous distributions...." (mathematica.stackexchange.com/questions/231460/…) which this distribution is not absolutely continuous. Have you had a change of heart? Or is the issue that Mathematica gives a result for something that doesn't exist?
– JimB
Nov 23, 2022 at 17:54