/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* Calculate the rolling mean of a series of values. */
/** * RollingMean<T> calculates a rolling mean of the values it is given. It * accumulates the total as values are added and removed. The second type * argument S specifies the type of the total. This may need to be a bigger * type in order to maintain that the sum of all values in the average doesn't * exceed the maximum input value. * * WARNING: Float types are not supported due to rounding errors.
*/ template <typename T, typename S> class RollingMean { private:
size_t mInsertIndex;
size_t mMaxValues;
Vector<T> mValues;
S mTotal;
public:
static_assert(!std::is_floating_point_v<T>, "floating-point types are unsupported due to rounding " "errors");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.