MCPcopy Create free account
hub / github.com/EdwardRaff/JSAT / variance

Method variance

JSAT/src/jsat/linear/SparseVector.java:380–399  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

378 }
379
380 @Override
381 public double variance()
382 {
383 if(varianceCache != null)
384 return varianceCache;
385
386 double mu = mean();
387 double tmp = 0;
388
389 double N = length();
390
391
392 for(int i = 0; i < used; i++)
393 tmp += Math.pow(values[i]-mu, 2);
394 //Now add all the zeros into it
395 tmp += (length()-used) * Math.pow(0-mu, 2);
396 tmp /= N;
397
398 return (varianceCache = tmp);
399 }
400
401 @Override
402 public double median()

Callers

nothing calls this directly

Calls 3

lengthMethod · 0.95
meanMethod · 0.45
powMethod · 0.45

Tested by

no test coverage detected