1 #ifndef GENESIS_UTILS_MATH_MOMENTS_H_
2 #define GENESIS_UTILS_MATH_MOMENTS_H_
82 Moments( It first, It last,
size_t ddof = 0 )
85 while( first != last ) {
94 Moments( std::initializer_list<double> list,
size_t ddof = 0 )
97 for(
auto const e : list ) {
118 m_old_ = m_new_ = val;
121 m_new_ = m_old_ + ( val - m_old_ ) /
static_cast<double>( count_ );
122 s_new_ = s_old_ + ( val - m_old_ ) * ( val - m_new_ );
140 return (( count_ > 1 ) ? s_new_ / (
static_cast<double>( count_ - ddof_ )) : 0.0 );
172 #endif // include guard