Releases: AlexandreHiroyuki/MovingAveragePlus
Moving Average Plus lib v4.4.1 - New repo warning
Let's make a clear begin
I had to make too many breaking changes to allow better addition of new features.
So, I decided to open a new repository for the following releases.
I cleaned a lot of code for both contributors and users of the library, so it should be a better experience to develop for and with it.
Also, the new version already has more features, like statistical functions, more control over the sum type, and better test coverage.
Please consider giving your support to the continuation of this project!
Moving Average Plus lib v4.4.0 - Unit Tests + Small Fixes
Changelog
- Added unit tests to
MovingAveragePlus
- Added CONTRIBUTING.md
- Fix
back()
method - Fix
resize()
method
Full Changelog: v4.3.1...v4.4.0
Moving Average Plus lib v4.3.1 - New Documentation + Syntax
Change Log
- Changed method name from "atIndex" to "at_index".
- Changed private method name from "_nextIndex" to "_next_index".
- Added a new documentation, built with docusaurus, and less reliant on third-party services. https://github.com/AlexandreHiroyuki/MovingAveragePlusDocs
Moving Average Plus lib v4.2.2 - Documentation + Free Memory
Change Log
- Improved Partials documentation readability on Platform IO Registry.
- Free the memory of partial's pointers.
Moving Average Plus lib v4.2.1 - Partials Documentation + PIO Registry
Change Log
- Added Partials documentation to Platform IO Registry.
- Updated some readme URLs.
Moving Average Plus lib v4.2.0 - Partials Documentation
Change Log
- Added Partials example code file.
- Updated readme's URLs.
MovingAverage Plus lib v4.1.4 - Library Metadata
Change Log
- Updated docs.
- Updated URLs and readme.
MovingAveragePlus lib v4.1.2 - PlatformIO and Static Pointer Cast
Change Log
- Made pointer cast use static_cast.
- Officially added MovingAveragePlus to PlatformIO Registry.
- Updated URLs to the new brand.
Moving Average+ lib v4.0.0 - Rebrand and Arduino Editor Online
Change Log
The difference between the IDE and the online editor environment is that the online editor automatically compiles with almost all libraries available in the manager pre-downloaded.
That unexpected behavior implies that the generic name of my library("MovingAverage.h") was conflicting with other libraries in the manager.
To solve this problem, the library had its name changed. Making the library name more recognizable and unique.
- Header file(".h") name changed to "MovingAveragePlus.h".
- The class name was changed to "MovingAveragePlus".
- The example file("moving_average_print.ino") was updated.
- Lib property name changed.
- The ReadMe title changed.
- Docs updated titles and class names.
- "keywords.txt" file was updated.
MovingAverage lib v3.2.0 - The Partials Concept
Change Log
The MovingAverage_ArduinoLibrary was born as a side project to solve a problem I had on a school project. As a consequence of the initial purpose, this library suffered from several problems that were tolerable for the project scope. But the moment I decided to publish the library open to anyone on the internet, I perceived how many usability details needed attention to make it usable for a wider range of purposes. So, I see this new version as a milestone. I pretend to repair the holes, clear unnecessary code and add a new feature built from the beginning with the performance and usability principles.
- ✨ Now the average is divided by the number of data points added until the moment. It doesn't start the calculation on the maximum array size anymore. —Due to this change, some methods became obsolete and, therefore, will be removed—
- Reset method is deprecated.
- Using a single number to initialize all array positions is also deprecated.
- Resize method is updated to work in the new paradigm.
- Clear method is updated to reset all array positions to 0, and bring the data points added counter back to 0.
- Documentation is all updated.
The Partials Concept
The Partials are a new way to efficiently calculate a partial average of data.
The get_by_brute method calculates the average of the values requested at each call and returns it immediately, without storing any data in memory.
This solution has linear complexity(O(n)) for the number of requested values in the average(passed as a parameter of the method).
Considering the infinite loop in which the algorithms are executed naturally by the practical use of microcontrollers (eg Arduino), the complexity will always grow in a polynomial way (O(n * m)).
In line with the concept of Dynamic Programming, memory usage can improve the time-consuming efficiency of algorithms because,
by storing your previous results it is possible to avoid wasting iterations spent to recalculate the old results.
Following this idea, the library's moving average uses a variable to hold the sum of all values,
only adding the new value and subtracting the oldest value, so to request the result it is only necessary to compute a division,
that otherwise, would be necessary to add every time the average was requested.
In this sense, the cost exchange becomes:
-
Brute Sum
Add new data - O(1) to write in the array
Average - O(n) to calculate the entire array per call -
Dynamic Sum
Add new data - O(2) = O(1) to write to array and add to sum
Calculate the mean - O(1) to calculate the division between sum and n_points
The idea of the new feature, therefore, is to recreate this behavior for the sums of partial sizes of the array, without creating the need to double the memory spent,
in the case of creating multiple copies of the same Moving Average structure, and without doubling the time spent adding these duplicates to the arrays.
The Partials concept was designed and reviewed by @AlexandreHiroyuki and implemented by @Amorim33