Package: distcan
Probabilitydistributions for python in theircanonical
form. Documentation (TODO: link)scipy.statsis the go to library for working with probability
distributions in python. It is an impressive package that exposes aninternally consistentAPI for working with almost 100 distributions.
But, there are some shortcomings…Instead of using the common names for the parameters of distributions
(e.g. Normal distribution mean and standard deviation being named mu
and sigma),scipy.statshas keyword arguments (or combinations of
them)loc,scale, andshapeassumethe roles of
canonical parametersRelated to the non-conventional parameter naming, the documentation
displays expressions for the pdf that often doesn’t match the
canonical form of the pdf easily found online or in standard
references. This makes it difficult to tell exactly what distribution
you are working withSome distributions are included inscipy.stats, but under a
different name a different documented form for the pdf. For example,
to create an InverseGamma(5, 6) distribution, you would callscipy.stats.invgamma(5, scale=6)EnterdistcanThedistcanlibrary aims to address these problems in an easily
extensible way. Some goals of this project areRepresent probability distributions in their canonical form, with
parameters given their standard namesExpose an API that is encompasses functionality inscipy.statsand`Distributions.jl<https://github.com/JuliaStats/Distributions.jl>`__
(a Julia package that motivated the creation ofdistcan), with
naming conventions that are consistent for users of both packagesHave documentation that accurately describes the distribution being
usedBy leveraging the great code inscipy.stats, we are well on our way
to completing these goals.FunctionalityAll the functionality ofscipy.stats, plus a few other convenience
methods, is exposed by each distribution. This includes the following
methods:pdf: evaluate the probability density functionlogpdf: evaluate the log of the pdfcdf: evaluate the cumulative density functionlogcdf: evaluate the log of the cdfrvs: draw random samples from the distributionmoment: evaluate nth non-central momentstats: some statistics of the RV (such as mean, variance,
skewness, kurtosis)fit(when available in scipy.stats): return the maximum
likelihood estimators of the distribution, given datasf(also given name ccdf): compute the survival function (or
complementary cumulative density function)logsf(also given name logccdf): compute the log of the survival
function (or complementary cumulative density function)isf: compute the inverse of the survival function (or
complementary cumulative density function)ppf(also give name quantile): compute the percent point function
(or quantile), which is the inverse of the cdf. This is commonly used
to compute critical values.loglikelihood(not in scipy): the loglikelihood of the
distribution with respect to all the samples in xinvlogcdf(not in scipy): evaluate inverse function of the logcdfcquantile(not in scipy): evaluate the complementary quantile
function. Equal tod.ppf(1-x)for x in (0, 1). Could be used to
compute the lower critical values of a distributioninvlogccdf(not in scipy): evaluate inverse function of the
logccdfAdditionally, each distribution has the following properties (accessed
asdist_object.property_name– i.e. without parenthesis):mean: the mean of the distributionvar: the var of the distributionstd: the std of the distributionskewness: the skewness of the distributionkurtosis: the kurtosis of the distributionmedian: the median of the distributionmode: the mode of the distributionisplaykurtic: boolean indicating if kurtosis is greater than zeroisleptokurtic: boolean indicating if kurtosis is less than zeroismesokurtic: boolean indicating if kurtosis is equal to zeroentropy: the entropy of the distributionparams(not in scipy): return a tuple of the distributions
parametersContributorsSpencer Lyon (spencer.lyon@stern.nyu.edu)