MCPcopy Create free account
hub / github.com/OxWearables/biobankAccelerometerAnalysis / std

Method std

src/accelerometer/java/AccStats.java:295–307  ·  view source on GitHub ↗
(double[] vals, double mean)

Source from the content-addressed store, hash-verified

293
294 // standard deviation
295 public static double std(double[] vals, double mean) {
296 if (vals.length == 0) {
297 return Double.NaN;
298 }
299 double var = 0; // variance
300 double len = vals.length; // length
301 for (int i = 0; i < len; i++) {
302 if (!Double.isNaN(vals[i])) {
303 var += Math.pow((vals[i] - mean), 2);
304 }
305 }
306 return Math.sqrt(var / len);
307 }
308
309
310 // same as above but matches R's (n-1) denominator (Bessel's correction)

Callers 4

calculateMADFeaturesMethod · 0.95
getAccStatsMethod · 0.95
countStuckValsMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected