9.4 Integer Distribution Families
Mathematically, integer distributions are commonly defined in one of two ways: over extended reals,
or over extended integers. The most common definitions use the extended reals, so the following
distribution object constructors return objects of type Real-Dist.
(Another reason is that the extended integers correspond with the type
(U Integer +inf.0 -inf.0). Values of this type have little support in Racket’s library.)
This leaves us with a quandary and two design decisions users should be aware of. The quandary is
that, when an integer distribution is defined over the reals, it has a cdf, but no
well-defined pdf: the pdf would be zero except at integer points, where it would be
Unfortunately, an integer distribution without a pdf is nearly useless.
In measure-theory parlance, the pdfs are defined with respect to counting measure,
while the cdfs are defined with respect to Lebesgue measure.
So the pdfs of these integer distributions are pdfs defined over integers, while their cdfs are
defined over reals.
Most implementations, such as R
’s, make the same design
choice. Unlike R’s, this implementation’s pdfs return +nan.0
when given non-integers,
for three reasons:
Their domain of definition is the integers.
Applying an integer pdf to a non-integer almost certainly indicates a logic error,
which is harder to detect when a program returns an apparently sensible value.
If this design choice turns out to be wrong and we change pdfs to return
0.0, this should affect very few programs. A change from 0.0 to
+nan.0 could break many programs.
Integer distributions defined over the extended integers are not out of the question, and may
show up in future versions of math/distributions if there is a clear need.
9.4.1 Bernoulli Distributions
Represents the Bernoulli distribution family parameterized by probability of success.
(bernoulli-dist prob) is equivalent to (binomial-dist 1 prob), but operations
on it are faster.
9.4.2 Binomial Distributions
Represents the binomial distribution family parameterized by count (number of trials) and
probability of success.
9.4.3 Geometric Distributions
Represents the geometric distribution family parameterized by success probability. The random
variable is the number of failures before the first success, or equivalently, the index of the
first success starting from zero.
9.4.4 Poisson Distributions
Represents the Poisson distribution family parameterized by the mean number of occurrences of