Code Monkey home page Code Monkey logo

statistics-3's Introduction

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());
}

statistics-3's People

Contributors

scottdky avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.