jonniezg / ewma Goto Github PK
View Code? Open in Web Editor NEWExponentially Weighted Moving Average Filter
License: MIT License
Exponentially Weighted Moving Average Filter
License: MIT License
Change:
EwmaT <int> filter(3, 100)
To:
#include <EwmaT.h>
// ...
EwmaT <int> filter(3, 100);
Well, the first is true but the second is false.
I've tested it, it's way slower than an optimized sliding average with one or more array.
On a reasonable amount of data, this method is around twice slower than what I've implemented !
Who can give me an example? There are already Arduino library files by jonnieZG,Exponential Weighted Moving Average.please give me a examples in arduino
The argument of non-using float is false.
When you look at the code, there're at least 3 divisions, which are very slow !
Arduino Nano compile does not have Serial.printf and even sprintf() does not have %f
FilteredADC:29:12: error: 'class HardwareSerial' has no member named 'printf'; did you mean 'print'?
Serial.printf("Raw=%d, Filter1=%.3f, Filter2=%.3f", raw, filtered1, filtered2);
^~~~~~
print
This breaks (returns high numbers instead of negatives when the "average" goes negative) when fed negative values.
EwmaT <long int> diff_ewmat(3, 10, 500);
...
filtered = diff_ewmat.filter(value);
This works (add/subtract an offset to keep everything positive):
EwmaT <long int> diff_ewmat(3, 10, 1000500);
...
filtered = diff_ewmat.filter(value+1000000)-1000000;
Sorry, C++ isn't nearly my day job, so maybe I'm expecting too much, but there's nothing to indicate this shouldn't work with signed numbers.
As far as I've understood the doc, all these lines should be equivalent:
EwmaT<int32_t> ewmat_sliding_Average(1, 125, 0); => result is ok !
EwmaT<int32_t> ewmat_sliding_Average(4, 500, 0); => result is KO !
EwmaT<int32_t> ewmat_sliding_Average(8, 1000, 0); => result is KO !
But it looks like, at some time in the calculation, there's an overflow (I add only values between 0 and 30000).
Some compile-time validation or so should be implemented to know what is the limit, .... or at least documented !
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.