The concept of first and higher order moments is captured by its own type. This allows dispatching the fit method.


A representation of statistical moments of a distribution

The following functions are supported

  • n_moments(m): get the number of recorded moments

The following getters return a single moment or throw an error if the moment has not been recorded (>N)

  • mean(m): get the first momemnt, i.e. the mean
  • var(m): get the second moment, i.e. the variance
  • skewness(m): get the third moment, i.e. the skewness
  • kurtosis(m): get the fourth moment, i.e. the kurtosis
  • getindex(m,i): get the ith moment, i.e. indexing m[i]

The basic implementation Moments is immutable and convert(AbstractArray, m::Moments) returns an SArray{N,T}.


m = Moments(1,0.2);
n_moments(m) == 2
var(m) == m[2]
kurtosis(m) # throws error because its above 2nd moment
moments(D, ::Val{N} = Val(2))

Get the first N moments of a distribution.

Produces an object of type AbstractMoments.


moments(LogNormal(), Val(4))  # first four moments 
moments(Normal())  # mean and variance


The concept of a pair (p,q), i.e. a probability in [0,1] and associated quantile is captured by its own type. This allows dispatching the fit method.


A representation of a pair (p,q), i.e. (percentile,quantile).


Several macros help to construct QuantilePoints

  • @qp(q,p) quantile at specified p: QuantilePoint(q,p)

For Float64-based percentiles there are shortcuts

  • @qp_ll(q0_025) quantile at very low p: QuantilePoint(q0_025,0.025)
  • @qp_l(q0_05) quantile at low p: QuantilePoint(q0_05,0.05)
  • @qp_m(median) quantile at median: QuantilePoint(median,0.5)
  • @qp_u(q0_95) quantile at high p: QuantilePoint(q0_95,0.95)
  • @qp_uu(q0_975) quantile at very high p: QuantilePoint(q0_975,0.975)

For constructing QuantilePoints with type of percentiles other than Float64, use the corresponding functions, that create a percentiles of the type of given quantile. E.g. for a Float32-based QuantilePoint at very low percentile

  • qp_ll(0.2f0) constructs a QuantilePoint(0.2f0,0.025f0)

There are macros/functions for some commonly used sets of QuantilePoints: 90% and 95% confidence intervals:

  • @qs_cf90(q0_05,q0_95)
  • @qs_cf95(q0_025,q0_975) -> Set([QuantilePoint(q0_025,0.025),QuantilePoint(q0_975,0.975)]))