plp:49: error: ‘Statistics’ does not name a type

plp.ino: In function ‘void loop()’:

plp:59: error: ‘stats’ was not declared in this scope

Should I copy folder ststistics to my libs folder in Arduino – i did it but this not work.

here is my (Your) code

#include

#include

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

}

Sample size affects the effect of bad data as well. A small sample size will reflect the bad data more readily, but would also clear it out more quickly as well. A larger sample size keeps the bad data points around longer, but they will have less of an effect.

]]>Here’s a video of one of my experiments that is using your Statistics library to efficiently smooth out the readings from a spectrum analyzer IC to make a nice, flicker-free light show on a series of LEDs: http://youtu.be/t4MN1q9X0Us

Thanks again!

Jim

]]>Note that m = m *((n-1)/n ) will not actually discard old data. Instead, it scales it so that the value you expect to store remains approximately bounded by N*mean for the mean, and N*(mean^2) for the sum of squares for the variance. If you put in a window length of two, and try the sequence {10, 10, 10, 20, 20, 20} you will see that you get a final number of 15, not the 2-observation mean of 20. If you used two pairs of accumulators you could implement a window that is constrained between N and 2N, however, by switching accumulators whenever the count reaches N, clearing the “new” accumulator , and always using both together for output. This would give you the long-term memoryless property that you desire.

The “well behaved” warning is because of large N*value – particularly on readings that can vary widely. Overflow errors would wipe out the accuracy of all subsequent readings, and are reasonably likely to happen if there is respectable variance and auto-correlated errors.

Why would I notice all this? Why, by burning myself while making a rate adaptive Morse decoder of course.

]]>