-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- add **getMedianAverage(nMedians)** removing bias - #22 - thanks to Peter Kowald - add example **RunningMedian_getMedianAverage.ino** - extended performance test - update readme.md
- Loading branch information
1 parent
64e310c
commit 9906a81
Showing
10 changed files
with
288 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
examples/RunningMedian_getMedianAverage/RunningMedian_getMedianAverage.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// | ||
// FILE: RunningMedian_getMedianAverage.ino | ||
// AUTHOR: Rob Tillaart | ||
// PURPOSE: test sketch to show the difference between | ||
// getAverage(nMedian) and getMedianAverage(nMedian). | ||
// URL: https://github.com/RobTillaart/RunningMedian | ||
|
||
|
||
#include <RunningMedian.h> | ||
|
||
RunningMedian samples = RunningMedian(11); | ||
|
||
|
||
void test_compare() | ||
{ | ||
Serial.println(__FUNCTION__); | ||
for (int x = 0; x < 9; x++) | ||
{ | ||
for (int y = 0; y <= x; y++) | ||
{ | ||
float a = samples.getAverage(y); | ||
float b = samples.getMedianAverage(y); | ||
Serial.print(x); | ||
Serial.print('\t'); | ||
Serial.print(y); | ||
Serial.print('\t'); | ||
Serial.print(a, 4); | ||
Serial.print('\t'); | ||
Serial.print(b, 4); | ||
Serial.print('\t'); | ||
Serial.println(a - b, 4); | ||
} | ||
Serial.println(); | ||
|
||
samples.add(x); | ||
} | ||
} | ||
|
||
|
||
void setup() | ||
{ | ||
Serial.begin(115200); | ||
Serial.print("Running Median Version: "); | ||
Serial.println(RUNNING_MEDIAN_VERSION); | ||
|
||
test_compare(); | ||
|
||
samples.clear(); | ||
samples.add(1); | ||
samples.add(2); | ||
|
||
delay(1000); | ||
uint32_t start = micros(); | ||
float f = samples.getMedianAverage(1); | ||
uint32_t stop = micros(); | ||
Serial.println(stop - start); | ||
Serial.println(f); | ||
} | ||
|
||
|
||
void loop() | ||
{ | ||
} | ||
|
||
|
||
// -- END OF FILE -- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.