rwldrn/johnny-five — pull request #150 by Protonk (2013-06-27 15:37:13+00:00)
Title: Exponential Smoother

I've updated the default smoother to an [exponential smoother](http://en.wikipedia.org/wiki/Exponential_smoothing). A single period low pass filter wasn't necessary given the minimal noise issues from the TinkerKit accelerometers. I'll re-evaluate later as needed but this should be solid as a default.

![nlsmooth](https://f.cloud.github.com/assets/390863/716822/3e00dc74-df3e-11e2-9173-7799a65e2daa.png)

That is output from the accelerometer in red and the smoother in blue. The value of `alpha` for that was set to `0.1`, which is very aggressive. right now the default is at `0.2` but I'll do some more testing to see what a responsible default might be (likely something that minimizes squared error for periods of rapid and slow movement).

![ex](https://f.cloud.github.com/assets/390863/716833/84a6cd3c-df3e-11e2-8ccc-514278d05c87.gif)

You can see here the output of the smoother for different values of `alpha`. Here the accelerometer data is black and the smoothed data is blue.

I've also changed two elements of the accelerometer constructor which are pertinent.

* The data is now generated dynamically based on the desired axes and parameters for the smoother. For the simple exponential smoother we only need smoothed and non-smoothed data but for something like a Holt-Winters smoother we will want a trend component. Eventually this will get kicked up to a `Sensor` object.
* I created a setter (a bit ad hoc, admittedly) for the accelerometer data. I did this because some smoothers may require multiple periods of data and it was getting silly to have a "last" and "current" object. This allows us to maintain a queue of data and keep the management of that queue outside of whatever smoother function which gets passed in. I'm open to comments on how to do this in a more idiomatic fashion.