A new univariate distribution type should implement all of the following methods:
- Core constructors
MyDistribution{T}(args[...])- We need to clarify whether constructors should handle input validation or not. There are use cases in which people want to avoid input validation.
params(d::MyDistribution{T})::Tuple: A tuple of the distribution's parameters in our canonical order.minimum(d::MyDistribution{T})::T: The lowest value in the support ofMyDistribution.maximum(d::MyDistribution{T})::T: The highest value in the support ofMyDistribution.location(d::MyDistribution{T})::T: The location of a location-scale family.scale(d::MyDistribution{T})::T: The scale of a location-scale family.partype(d::MyDistribution{T}): TBDmean(d::MyDistribution{T})::T: The theoretical mean of the distribution.median(d::MyDistribution)::T: The theoretical median of the distribution.mode(d::MyDistribution)::T: An arbitary theoretical mode of the distribution.modes(d::MyDistribution)::Tuple{T}: The theoretical modes of the distribution.var(d::MyDistribution)::T: The theoretical variance of the distribution.skewness(d::MyDistribution)::T: The theoretical skewness of the distribution.kurtosis(d::MyDistribution)::T: The theoretical kurtosis of the distribution.entropy(d::MyDistribution)::T: The theoretical entropy of the distribution.pdf(d::MyDistribution, x::Real)::promote_type(T, x): The PDF of the distribution evaluated atx.logpdf(d::MyDistribution, x::Real)::promote_type(T, x): : The log of the PDF of the distribution evaluated atx.cdf(d::MyDistribution, x::Real)::promote_type(T, x): The CDF of the distribution evaluated atx.ccdf(d::MyDistribution, x::Real)::promote_type(T, x): 1 minus the CDF of the distribution evaluated atx.mgf(d::MyDistribution, x::Real)::promote_type(T, x): The moment generating function of the distribution evaluated atx.cf(d::MyDistribution, x::Real)::promote_type(T, x): : The characteristic function of the distribution evaluated atx.rand(d::MyDistribution{T})::T: A random sample from the distribution.fit_mle(d::MyDistribution{T}, x)::MyDistribution{T}: An instance of the distribution fit by MLE to data.
Maybe a keyword argument in constructors that defaults to
true, e.g.MyDistribution{T}(a, b, ...; validate=true)? That way if people really need to turn off input validation they can. If we do that, I'd sort of prefer that method to be undocumented, as I think we should encourage people to use correct, sensible inputs.What do we do for discrete distributions defined on the positive integers with no upper bound, like the geometric distribution?
Infis a float, but all values in the support are integers.Personally I'd prefer the long-form names, i.e.
parameters,parametertype(assuming that's whatpartypeis), andcharacteristic(or similar), but I don't feel too strongly about it.This is awesome. Thanks so much for writing it out! This will be a huge step forward for the package.