Common Lisp Package: CL-NUM-UTILS.STATISTICS

README:

FUNCTION

Public

CENTRAL-SAMPLE-MOMENTS-DEGREE (CENTRAL-SAMPLE-MOMENTS)

Return the degree of CENTRAL-SAMPLE-MOMENTS.

EMPIRICAL-QUANTILE (SORTED-VECTOR Q)

Return the empirical quantile of a vector of real numbers, sorted in ascending order (not checked). Uses a 0.5 correction.

EMPIRICAL-QUANTILE-PROBABILITIES (N)

Probabilities that correspond to the empirical quantiles of a vector of length N. That is to say, (== (quantiles sample (empirical-quantile-probabilities (length sample))) sample) for any vector SAMPLE.

ENSURE-SORTED-VECTOR (OBJECT)

Return the elements of OBJECT as a vector (or reals) sorted in ascending order.

POOL (&REST ACCUMULATORS)

Pool ACCUMULATORS.

Undocumented

SORTED-REALS-ELEMENTS (SORTED-REALS)

Private

CENTRAL-SAMPLE-MOMENTS-M (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

CENTRAL-SAMPLE-MOMENTS-S2 (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

CENTRAL-SAMPLE-MOMENTS-S3 (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

CENTRAL-SAMPLE-MOMENTS-S4 (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

CENTRAL-SAMPLE-MOMENTS-W (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

SORT-REALS (SEQUENCE)

Return a SORTED-REALS structure.

SORTED-REALS-ORDERED-ELEMENTS (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

SORTED-REALS-UNORDERED-ELEMENTS (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

TALLY-MIXIN-W (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

Undocumented

SETFCENTRAL-SAMPLE-MOMENTS-M (NEW-VALUE INSTANCE)

CENTRAL-SAMPLE-MOMENTS-P (OBJECT)

SETFCENTRAL-SAMPLE-MOMENTS-S2 (NEW-VALUE INSTANCE)

SETFCENTRAL-SAMPLE-MOMENTS-S3 (NEW-VALUE INSTANCE)

SETFCENTRAL-SAMPLE-MOMENTS-S4 (NEW-VALUE INSTANCE)

SETFCENTRAL-SAMPLE-MOMENTS-W (NEW-VALUE INSTANCE)

COPY-CENTRAL-SAMPLE-MOMENTS (INSTANCE)

COPY-SORTED-REALS (INSTANCE)

COPY-TALLY-MIXIN (INSTANCE)

MAKE-CENTRAL-SAMPLE-MOMENTS (&KEY ((W DUM76) 0) ((M DUM77) 0.0d0) ((S2 DUM78) 0.0d0) ((S3 DUM79) 0.0d0) ((S4 DUM80) 0.0d0))

MAKE-SORTED-REALS (&KEY ((ORDERED-ELEMENTS DUM1122) #()) ((UNORDERED-ELEMENTS DUM1123) NIL))

MAKE-TALLY-MIXIN (&KEY ((W DUM23) 0))

SETFSORTED-REALS-ORDERED-ELEMENTS (NEW-VALUE INSTANCE)

SORTED-REALS-P (OBJECT)

SETFSORTED-REALS-UNORDERED-ELEMENTS (NEW-VALUE INSTANCE)

TALLY-MIXIN-P (OBJECT)

SETFTALLY-MIXIN-W (NEW-VALUE INSTANCE)

MACRO

Private

&SORTED-REALS (&WHOLE WHOLE1163 ORDERED-ELEMENTS UNORDERED-ELEMENTS)

LET+ form for slots of the structure SORTED-REALS.

&SORTED-REALS-R/O (&WHOLE WHOLE1205 ORDERED-ELEMENTS UNORDERED-ELEMENTS)

LET+ form for slots of the structure SORTED-REALS. Read-only.

DEFINE-CENTRAL-SAMPLE-MOMENT (FUNCTION (VARIABLE DEGREE) &BODY BODY)

FIXME documentation, factor our general part

GENERIC-FUNCTION

Public

ADD (ACCUMULATOR OBJECT &OPTIONAL WEIGHT)

Add OBJECT to ACCUMULATOR with WEIGHT (defaults to 1 if not given). Return OBJECT. NILs are ignored by the accumulator, unless a specialized method decides otherwise.

CENTRAL-M2 (OBJECT &KEY WEIGHTS)

Second central moment. For samples, normalized by the total weight (and thus not the unbiased estimator, see VARIANCE).

CENTRAL-M3 (OBJECT &KEY WEIGHTS)

Third central moment.

CENTRAL-M4 (OBJECT &KEY WEIGHTS)

Fourth central moment.

CENTRAL-SAMPLE-MOMENTS (OBJECT &KEY DEGREE WEIGHTS (DEGREE *CENTRAL-SAMPLE-MOMENTS-DEFAULT-DEGREE*))

Return a CENTRAL-SAMPLE-MOMENTS object that allows the calculation of the central sample moments of OBJECT up to the given DEGREE. When WEIGHTS are given, they need to be a sequence of matching length.

ENSURE-SORTED-REALS (OBJECT)

Return the contents of OBJECT as a SORTED-REALS.

KURTOSIS (OBJECT &KEY WEIGHTS)

Kurtosis FIXME talk about bias, maybe implement unbiased?

MEAN (OBJECT &KEY WEIGHTS)

The mean of elements in OBJECT.

MEDIAN (OBJECT)

Median of OBJECT.

QUANTILE (OBJECT Q)

Return an element at quantile Q. May be an interpolation or an approximation, depending on OBJECT and Q. NOTE: Extensions should define methods for QUANTILES, not QUANTILE.

QUANTILES (OBJECT QS)

Multiple quantiles (see QUANTILE). NOTE: Extensions should define methods for QUANTILES, not QUANTILE.

SD (OBJECT &KEY WEIGHTS)

Standard deviation. For samples, the square root of the unbiased estimator (see VARIANCE).

SKEWNESS (OBJECT &KEY WEIGHTS)

Skewness FIXME talk about bias, maybe implement unbiased?

TALLY (ACCUMULATOR)

The total weight of elements in ACCUMULATOR.

VARIANCE (OBJECT &KEY WEIGHTS)

Variance of OBJECT. For samples, normalized by the weight-1 (and thus unbiased if certain assumptions hold, eg weights that count frequencies).

Private

POOL2 (ACCUMULATOR1 ACCUMULATOR2)

Pool two accumulators. When they are of a different type, the resulting accumulator will be downgraded to the level afforded by the information available in the accumulators.

VARIABLE

Public

*CENTRAL-SAMPLE-MOMENTS-DEFAULT-DEGREE*

Default degree for (weighted) central sample moments.

CLASS

Public

CENTRAL-SAMPLE-MOMENTS (OBJECT &KEY DEGREE WEIGHTS (DEGREE *CENTRAL-SAMPLE-MOMENTS-DEFAULT-DEGREE*))

Central sample moments calculated on-line/single-pass. M weighted mean S2 weighted sum of squared deviations from the mean, not calculated when NIL S3 weighted sum of cubed deviations from the mean, not calculated when NIL S4 weighted sum of 4th power deviations from the mean, not calculated when NIL Allows on-line, numerically stable calculation of moments. See cite{bennett2009numerically} and cite{pebay2008formulas} for the description of the algorithm. M_2, ..., M_4 in the paper are s2, ..., s4 in the code.

SORTED-REALS

Accumulator which sorts elements. ELEMENTS return the sorted elements.

Private

TALLY-MIXIN

Mixin structure that contains a tally. Not exported. W is the total weight.

CONDITION

Public

Undocumented

EMPTY-ACCUMULATOR

INFORMATION-NOT-COLLECTED-IN-ACCUMULATOR

NOT-ENOUGH-ELEMENTS-IN-ACCUMULATOR