phyphox Forums
How to use movingaverage - Printable Version

+- phyphox Forums (https://phyphox.org/forums)
+-- Forum: App-Feedback (https://phyphox.org/forums/forumdisplay.php?fid=6)
+--- Forum: Bugs and Problems (https://phyphox.org/forums/forumdisplay.php?fid=9)
+--- Thread: How to use movingaverage (/showthread.php?tid=2119)



How to use movingaverage - SiFreZi - 03-31-2025

Hi,

I am trying to use the movingaverage function and am constantly failing.
I have no clue how that function should work.
Can someone please post a simple example?
My not working code looks like this:
Code:
<phyphox xmlns="https://phyphox.org/xml" version="1.18">
  <title>New Experiment</title>
  <category>No Category</category>
  <data-containers>
    <container size="0">x</container>
    <container size="0">xAvg</container>
  </data-containers>
  <input>
    <sensor type="linear_acceleration">
      <output component="x">x</output>
    </sensor>
  </input>
  <analysis>
    <movingaverage>
      <input as="data">x</input>
      <input as="width" type="value">10</input>
      <output as="data">xAvg</output>
    </movingaverage>
  </analysis>
  <views>
    <view label="New View">
      <value label="xAvg">
        <input>xAvg</input>
      </value>
    </view>
  </views>
</phyphox>



RE: How to use movingaverage - Jens Noriʇzsɔɥ - 04-01-2025

The value field is updated at the rate of the analysis block, so nothing really to see here at about 100 Hz. In order to get a better understanding of what's going on, it makes sense to plot the containers against time. You will observe then that the “current” value is averaged with “width” previous values (a total of 11 data points in your case).

There is a rather common … unintendedness in your .phyphox file: you would like to keep the x data, accordingly
Code:
    <movingaverage>
      <input as="data" keep="true">x</input>
      <input as="width" type="value">10</input>
      <output as="data">xAvg</output>
    </movingaverage>

Without “keep” the x container is cleared when exiting this block. Do not use “append” for xAvg. I still need to find a clever way to optimise taking the moving average, so for the time being better take all recorded data in each run.