[#BloombergLP-bdlsta-Moment-0d] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlsta.adoc[bdlsta]::xref:BloombergLP/bdlsta/Moment-08.adoc[Moment]<BloombergLP::bdlsta::MomentLevel::e_M2> :relfileprefix: ../../ :mrdocs: This class provides efficient and accurate online algorithms for calculating mean, variance, skew, and kurtosis. The class provides template specializations, so that no unnecessary data members will be kept or unnecessary calculations done. The online algorithms used are Welford for variance, and the stable M3 and M4 are taken from: https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Higher‐order_statistics == Synopsis Declared in `<bdlsta_moment.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<> class xref:BloombergLP/bdlsta/Moment-08.adoc[Moment]<BloombergLP::bdlsta::MomentLevel::e_M2>; ---- == Description The formula for sample skewness is taken from: http://www.macroption.com/skewness‐formula/ The formula for sample excess kurtosis is taken from: http://www.macroption.com/kurtosis‐formula/ == Enums [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlsta/Moment-0d/_04enum.adoc[`Unnamed enum`] | Status codes returned by statistical computations. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlsta/Moment-0d/add.adoc[`add`] | Add the specified `value` to the data set. | xref:BloombergLP/bdlsta/Moment-0d/count.adoc[`count`] | Returns the number of elements in the data set. | xref:BloombergLP/bdlsta/Moment-0d/kurtosis.adoc[`kurtosis`] | Return the kurtosis of the data set. The behavior is undefined unless `4 <= count` and the variance is not zero. | xref:BloombergLP/bdlsta/Moment-0d/kurtosisIfValid.adoc[`kurtosisIfValid`] | Load into the specified `result`, the kurtosis of the data set. Return 0 on success, and a non‐zero value otherwise. Specifically, `e_INADEQUATE_DATA` is returned if `4 > count` or the variance is zero. | xref:BloombergLP/bdlsta/Moment-0d/mean.adoc[`mean`] | Return the mean of the data set. The behavior is undefined unless `1 <= count`. | xref:BloombergLP/bdlsta/Moment-0d/meanIfValid.adoc[`meanIfValid`] | Load into the specified `result`, the mean of the data set. Return 0 on success, and a non‐zero value otherwise. Specifically, `e_INADEQUATE_DATA` is returned if `1 > count`. | xref:BloombergLP/bdlsta/Moment-0d/skew.adoc[`skew`] | Return skew of the data set. The behavior is undefined unless `3 <= count` or the variance is zero. | xref:BloombergLP/bdlsta/Moment-0d/skewIfValid.adoc[`skewIfValid`] | Load into the specified `result`, the skew of the data set. Return 0 on success, and a non‐zero value otherwise. Specifically, `e_INADEQUATE_DATA` is returned if `3 > count` or the variance is zero. | xref:BloombergLP/bdlsta/Moment-0d/variance.adoc[`variance`] | Return the variance of the data set. The behavior is undefined unless `2 <= count`. | xref:BloombergLP/bdlsta/Moment-0d/varianceIfValid.adoc[`varianceIfValid`] | Load into the specified `result`, the variance of the data set. Return 0 on success, and a non‐zero value otherwise. Specifically, `e_INADEQUATE_DATA` is returned if `2 > count`. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#