Smoothing on time series data points

Hi,
I need a function sometimes called “moving average” on time series data measurements to reduce noise. I’m still a beginner using Kodular, so I have not yet succeed in writing an own (working) function for it.

Has anyone done this or is there an extension that can be used? An extension would be super :slight_smile:

I am a bit surprised that I have not been able to find anything on the forum about this kind of need as I think it should be a quite common need to reduce noise from various type of sensors.

Simple Moving Average ,
Weighted Moving Average, Exponential Moving Average ?

Simple moving average would be good enough.

It is not pretty (and sorry it is in App Inventor blocks) but this procedure will give a moving average set of values from a list of values. You can enter your chosen level of average e.g 1 will be the same as the data, 2 will half the values, 3 will 1/3 the values and so on. At some point a high enough number will give you a flat line!

what global avgdata could be like:

image

2 Likes

2 Likes

Thanks! Really interesting. I will test this later today :slight_smile: The first case i will test it for is RSSI measurements using BluetoothLE, HM-10 and Arduino (using the tiny but powerful XIAO from SEEED). The RSSI measurement works great but the signal strength value really need a moving average.

The logic I applied considers even the newest value (last entry -FIFO), excluding, according to the period, the oldest ones.
:thumbsup:

Hi, I tried this alternative but I get a runtime error.
image

There is a difference however:
image

But I thought my implementation should be the same. But I cannot find the one you used (red marking)

Use

bild
bild

2 Likes

Thanks!
I need to learn a lot… but obviously no difference regarding the runtime error.

avgdata should be list

bild

2 Likes

In addition, it is your list of input values, values ​​that will be used for the functions mentioned above.

SMA ,EMA And WMA
Or…

Screenshot_20210113-125152

Screenshot_20210113-125033

Input data for your app.

2 Likes

Now it works :slight_smile:

Made a minor adjustments to fit my application:

  • I only need the last averaged value of the moving average so I replaced the list with a single variable.

Thanks for all help!

:pray:

I have added an example of “global avgdata” to my first post

To be honest I didn’t even see it, as I was only looking at @Anders_Hansson’s blocks…Sorry!

No, don’t be, I added after you posted :wink:

1 Like