distionary 0.2.0
This cycle adds support objects: a distribution now says where it places its probability, and the routines computing from it — quantiles and moments — use that to handle atoms exactly rather than approximately. Code that uses the built-in dst_*() distributions is unaffected. Most of the breaking changes are in distribution(), so they reach only distributions built by hand; the exception is length() and is.na(), which now answer about the distribution itself.
Breaking changes
distribution()now requires a.support, saying where the distribution places probability. See?distribution, and the “The Support of a Distribution” vignette for why it is asked for..vtypeis defunct, and errors with a message pointing at.support. The variable type is derived from the support.rangeandvtypeare derived from the support rather than stated, anddistribution()refuses them as entries. Both remain properties, reachable througheval_property()like any other.length(),is.na()andas.list()answer about the distribution rather than about the list of properties it is built from:length()gives 1, not 11, andis.na()gives a single logical,TRUEfor the Null distribution. The properties are unchanged; see?length.dst.
Supports
New support objects say where a distribution places probability, tracking its atoms explicitly:
discrete(),continuous(), andmixed(discrete =, continuous =). Retrieve one withsupport(), its two parts withatoms()andregions(), and test one withis_support().empty_support(), withis_empty_support(). No distribution has an empty support, but operations on supports need something to return.Supports can now be manipulated, not only built:
support_union(),support_restrict()andsupport_transform(), withsupport_shift(),support_scale()andsupport_reciprocal()for the common maps;support_add_atoms()andsupport_drop_atoms(); andsupport_contains()andsupport_has_atom(). There is deliberately no intersection.All built-in
dst_*()families carry a support, so their atoms are known explicitly —dst_pois()reports the atoms0, 1, 2, ....Re-exported the
discretesconstructors used to describe atomic supports, so they work without attaching that package:natural0(),natural1(),integers(),arithmetic()andas_discretes().
Evaluation
Moments (
mean(),variance(),stdev(),skewness(),kurtosis()) are computed numerically for discrete and mixed distributions, not only continuous ones: a sum over the atoms plus integration over the regions. Infinite atomic supports are walked outward, and a moment that never settles returnsNaN.Quantiles derived through the property network are considerably faster, solving every requested probability in one vectorised bisection rather than a separate search for each. A probability landing inside an atom’s jump returns that atom exactly, and the 0- and 1-quantiles come from the support, so an unbounded distribution gives
-InfandInf. Discrete and mixed distributions raised an error on this path before.
Distributions
dst_pearson3(), and the underlyingppearson3(),dpearson3(),qpearson3()andrpearson3(), accept a negativeshape: the Pearson Type III reflected aboutlocation, giving the negatively-skewed, upper-bounded form.dst_lp3()supports negative skew on the log scale. Zero skew is treated as a log-normal distribution.
