1 #ifndef HRK_MOVING_AVERAGE_H
2 #define HRK_MOVING_AVERAGE_H
30 : buffer_size_(size), total_(0)
32 if (buffer_size_ == 0) {
35 buffer_set(buffer_size_, initial_value);
45 buffer_set(buffer_size_, value);
67 total_ -= buffer_.front();
70 buffer_.push_back(value);
72 average_ = total_ / buffer_size_;
81 std::deque<T> buffer_;
86 void buffer_set(
size_t size, T value)
88 buffer_.assign(size, value);
90 total_ = average_ * size;
T average(void)
平均値の取得
Definition: Moving_average.hpp:53
T push_back(T value)
値の追加
Definition: Moving_average.hpp:65
void set_average_value(T value)
格納されている平均値の更新
Definition: Moving_average.hpp:43
Moving_average(size_t size, T initial_value=0)
コンストラクタ
Definition: Moving_average.hpp:29
移動平均のテンプレート
Definition: Moving_average.hpp:21