[#BloombergLP-bdlsta-Moment-08]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlsta.adoc[bdlsta]::Moment
:relfileprefix: ../../
:mrdocs:

Online calculator for mean, variance, skew, and kurtosis&period;

== Synopsis

Declared in `&lt;bdlsta&lowbar;moment&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;xref:BloombergLP/bdlsta/MomentLevel/Enum.adoc[MomentLevel::Enum] ML&gt;
class Moment;
----

== Description

This class provides efficient and accurate online algorithms for calculating mean, variance, skew, and kurtosis&period; The class provides template specializations, so that no unnecessary data members will be kept or unnecessary calculations done&period; The online algorithms used are Welford for variance, and the stable M3 and M4 are taken from&colon; https&colon;&sol;&sol;en&period;wikipedia&period;org&sol;wiki&sol;Algorithms&lowbar;for&lowbar;calculating&lowbar;variance&num;Higher&hyphen;order&lowbar;statistics

The formula for sample skewness is taken from&colon; http&colon;&sol;&sol;www&period;macroption&period;com&sol;skewness&hyphen;formula&sol;

The formula for sample excess kurtosis is taken from&colon; http&colon;&sol;&sol;www&period;macroption&period;com&sol;kurtosis&hyphen;formula&sol;

== Enums

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlsta/Moment-08/_04enum.adoc[`Unnamed enum`] 
| Status codes returned by statistical computations&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlsta/Moment-08/add.adoc[`add`] 
| Add the specified `value` to the data set&period;
| xref:BloombergLP/bdlsta/Moment-08/count.adoc[`count`] 
| Return the number of elements in the data set&period;
| xref:BloombergLP/bdlsta/Moment-08/kurtosis.adoc[`kurtosis`] 
| Return the kurtosis of the data set&period; The behavior is undefined unless `4 &lt;&equals; count` and the variance is not zero&period;
| xref:BloombergLP/bdlsta/Moment-08/kurtosisIfValid.adoc[`kurtosisIfValid`] 
| Load kurtosis into `result` when data is sufficient&period;
| xref:BloombergLP/bdlsta/Moment-08/mean.adoc[`mean`] 
| Return the mean of the data set&period; The behavior is undefined unless `1 &lt;&equals; count`&period;
| xref:BloombergLP/bdlsta/Moment-08/meanIfValid.adoc[`meanIfValid`] 
| Load mean into `result` when data is sufficient&period;
| xref:BloombergLP/bdlsta/Moment-08/skew.adoc[`skew`] 
| Return skew of the data set&period; The behavior is undefined unless `3 &lt;&equals; count` or the variance is zero&period;
| xref:BloombergLP/bdlsta/Moment-08/skewIfValid.adoc[`skewIfValid`] 
| Load skew into `result` when data is sufficient&period;
| xref:BloombergLP/bdlsta/Moment-08/variance.adoc[`variance`] 
| Return the variance of the accumulated sample&period;
| xref:BloombergLP/bdlsta/Moment-08/varianceIfValid.adoc[`varianceIfValid`] 
| Load variance into `result` when data is sufficient&period;
|===


== Specializations

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlsta/Moment-01.adoc[`Moment&lt;BloombergLP&colon;&colon;bdlsta&colon;&colon;MomentLevel&colon;&colon;e&lowbar;M1&gt;`] 
| Online calculator for mean, variance, skew, and kurtosis&period;
| xref:BloombergLP/bdlsta/Moment-0d.adoc[`Moment&lt;BloombergLP&colon;&colon;bdlsta&colon;&colon;MomentLevel&colon;&colon;e&lowbar;M2&gt;`] 
| Online calculator for mean, variance, skew, and kurtosis&period;
| xref:BloombergLP/bdlsta/Moment-0a.adoc[`Moment&lt;BloombergLP&colon;&colon;bdlsta&colon;&colon;MomentLevel&colon;&colon;e&lowbar;M3&gt;`] 
| Online calculator for mean, variance, skew, and kurtosis&period;
| xref:BloombergLP/bdlsta/Moment-09.adoc[`Moment&lt;BloombergLP&colon;&colon;bdlsta&colon;&colon;MomentLevel&colon;&colon;e&lowbar;M4&gt;`] 
| Online calculator for mean, variance, skew, and kurtosis&period;
|===



[.small]#Created with https://www.mrdocs.com[MrDocs]#
