Skip to content

provideyourown/statistics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Statistics Library (version: 1.0)

© 2012-2013 Scott Daniels <provideyourown.com> under GNU General Public License

The Statistics Library permits you to easily perform statistical analysis on data collected. This information can be useful for determining data quality as well as smoothing jittery readings such as those from touch sensors.

In order to conserve precious SRAM when necessary, two versions of the library are available:

IntStatistics.h - uses only integer math Statistics.h - uses floating point math

The inclusion of floating point math in an Arduino sketch will consume over 200 bytes of SRAM in overhead.

Methods

Construction & Configuration

Statistics(numSamples) - specify the number of samples to be collected

void setNewSampleSize(numSamples) - change the sample size (will reset any data collected)

void reset() - reset the collected data

Adding data

void addData(val) - add a data point to the collection

Data Analysis

[type] mean() - the arthemetic mean of the data collected

[type] variance() - the variance of the data

[type] stdDeviation() - the standard deviation (NOT available in the integer version)

[type] maxVal() - the maximum data point

[type] minVal() - the minimum data point

Usage example

#include <Statistics.h>

Statistics stats(10);

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  int data = analogRead(A0);
  stats.addData(data);
  
  Serial.print("Mean: ");
  Serial.print(stats.mean());
  Serial.print(" Std Dev: ");
  Serial.println(stats.stdDeviation());
}

About

A statistics library for the Arduino and other microcontrollers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages