This library performs a quick calculation of the median of an array in Arduino using the QuickSelect algorithm modified by Wirth.
For more information, consult the entry Fast median calculation in Arduino with Wirth QuickSelect.
The QuickMedian library has a single static method for calculating the median. It is not necessary, therefore, to instantiate an object.
Templates are used to work with different types of variables (int, long, float…). The library includes two examples, one for int and one for float.
To calculate the median of a vector, the GetMedian function is used
int med = QuickMedian<int>::GetMedian(items, numItems);
The QuickMedian library includes the following examples to illustrate its use.
- QuickMedianInt: Example of use for integer variables.
- QuickMedianFloat: Example of use for float variables.
- Download the latest version from GitHub
- Unzip the file
- Copy it to your libraries folder (usually My Documents\Arduino\libraries)
- Restart the Arduino IDE