Back to project page yousense-android-tracker.
The source code is released under:
Energy-efficent motion and location tracker for Android. Based on Mattias's power and tracking work. I plan to release it as GPL, once I have a paper published that goes with it. Might also release i...
If you think the Android project yousense-android-tracker listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.linnap.locationtracker.movement; //w w w . ja v a 2s .c om /** * Fixed-size buffer for calculating statistical summaries (average, variance) of data. * Silently stops accumulating on overflow. */ public class StatsAccumulator { int size; float[] buffer; int count; float sum; public StatsAccumulator(int size) { this.size = size; this.buffer = new float[size]; this.count = 0; this.sum = 0; } public void clear() { count = 0; sum = 0; } public void add(float value) { if (count < size - 1) { buffer[count++] = value; sum += value; } } public float mean() { return sum / count; } public float variance() { float m = mean(); float squaredDifference = 0; for (int i = 0; i < count; ++i) squaredDifference += (buffer[i] - m) * (buffer[i] - m); return squaredDifference / count; } }