Updated so that statistics are sparsely populated instead of having a point on every change.  Added tolerance for noise on sensor.