<bdo id='Dmgyy'></bdo><ul id='Dmgyy'></ul>

      <small id='Dmgyy'></small><noframes id='Dmgyy'>

    1. <i id='Dmgyy'><tr id='Dmgyy'><dt id='Dmgyy'><q id='Dmgyy'><span id='Dmgyy'><b id='Dmgyy'><form id='Dmgyy'><ins id='Dmgyy'></ins><ul id='Dmgyy'></ul><sub id='Dmgyy'></sub></form><legend id='Dmgyy'></legend><bdo id='Dmgyy'><pre id='Dmgyy'><center id='Dmgyy'></center></pre></bdo></b><th id='Dmgyy'></th></span></q></dt></tr></i><div id='Dmgyy'><tfoot id='Dmgyy'></tfoot><dl id='Dmgyy'><fieldset id='Dmgyy'></fieldset></dl></div>
      <tfoot id='Dmgyy'></tfoot>
      <legend id='Dmgyy'><style id='Dmgyy'><dir id='Dmgyy'><q id='Dmgyy'></q></dir></style></legend>
    2. 在 C++ 中计算滚动/移动平均值

      时间:2023-07-20
      <legend id='hcImN'><style id='hcImN'><dir id='hcImN'><q id='hcImN'></q></dir></style></legend>

        <tfoot id='hcImN'></tfoot>

      • <small id='hcImN'></small><noframes id='hcImN'>

              <bdo id='hcImN'></bdo><ul id='hcImN'></ul>
                <i id='hcImN'><tr id='hcImN'><dt id='hcImN'><q id='hcImN'><span id='hcImN'><b id='hcImN'><form id='hcImN'><ins id='hcImN'></ins><ul id='hcImN'></ul><sub id='hcImN'></sub></form><legend id='hcImN'></legend><bdo id='hcImN'><pre id='hcImN'><center id='hcImN'></center></pre></bdo></b><th id='hcImN'></th></span></q></dt></tr></i><div id='hcImN'><tfoot id='hcImN'></tfoot><dl id='hcImN'><fieldset id='hcImN'></fieldset></dl></div>
                  <tbody id='hcImN'></tbody>
              • 本文介绍了在 C++ 中计算滚动/移动平均值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我知道这可以通过 boost 实现:

                I know this is achievable with boost as per:

                使用boost::accumulators,如何重置滚动窗口大小,是否保留额外的历史记录?

                但我真的很想避免使用 boost.我已经用谷歌搜索过,但没有找到任何合适或可读的例子.

                But I really would like to avoid using boost. I have googled and not found any suitable or readable examples.

                基本上,我想使用最近的 1000 个数字作为数据样本来跟踪正在进行的浮点数流的移动平均值.

                Basically I want to track the moving average of an ongoing stream of a stream of floating point numbers using the most recent 1000 numbers as a data sample.

                实现这一目标的最简单方法是什么?

                What is the easiest way to achieve this?

                我尝试使用圆形阵列、指数移动平均线和更简单的移动平均线,发现圆形阵列的结果最适合我的需要.

                I experimented with using a circular array, exponential moving average and a more simple moving average and found that the results from the circular array suited my needs best.

                推荐答案

                您只需要一个包含 1000 个元素的循环数组(循环缓冲区),您可以在其中将元素添加到前一个元素并存储它.

                You simply need a circular array (circular buffer) of 1000 elements, where you add the element to the previous element and store it.

                它变成了一个递增的和,你总是可以得到任意两对元素之间的和,然后除以它们之间的元素数,得到平均值.

                It becomes an increasing sum, where you can always get the sum between any two pairs of elements, and divide by the number of elements between them, to yield the average.

                这篇关于在 C++ 中计算滚动/移动平均值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:C++11 std::bind 和 boost::bind 的区别 下一篇:C++ 线程池

                相关文章

                <tfoot id='KeuY0'></tfoot>

              • <legend id='KeuY0'><style id='KeuY0'><dir id='KeuY0'><q id='KeuY0'></q></dir></style></legend>

                  <bdo id='KeuY0'></bdo><ul id='KeuY0'></ul>

                <small id='KeuY0'></small><noframes id='KeuY0'>

                <i id='KeuY0'><tr id='KeuY0'><dt id='KeuY0'><q id='KeuY0'><span id='KeuY0'><b id='KeuY0'><form id='KeuY0'><ins id='KeuY0'></ins><ul id='KeuY0'></ul><sub id='KeuY0'></sub></form><legend id='KeuY0'></legend><bdo id='KeuY0'><pre id='KeuY0'><center id='KeuY0'></center></pre></bdo></b><th id='KeuY0'></th></span></q></dt></tr></i><div id='KeuY0'><tfoot id='KeuY0'></tfoot><dl id='KeuY0'><fieldset id='KeuY0'></fieldset></dl></div>