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

Method variance

JSAT/src/jsat/linear/Vec.java:526–544  ·  view source on GitHub ↗

Computes the variance of the values in this vector, which is #standardDeviation() 2 @return the variance

()

Source from the content-addressed store, hash-verified

524 * @return the variance
525 */
526 public double variance()
527 {
528 double mu = mean();
529 double variance = 0;
530
531 double N = length();
532
533
534 int used = 0;
535 for(IndexValue x : this)
536 {
537 used++;
538 variance += Math.pow(x.getValue()-mu, 2)/N;
539 }
540 //Now add all the zeros we skipped into it
541 variance += (length()-used) * Math.pow(0-mu, 2)/N;
542
543 return variance;
544 }
545
546 /**
547 * Returns the median value in this vector

Callers 9

testSampleAndStatsMethod · 0.95
testSampleMethod · 0.95
testSampleMethod · 0.95
testSampleMethod · 0.95
standardDeviationMethod · 0.95
testVarianceMethod · 0.45
testVarianceMethod · 0.45
testVarianceMethod · 0.45
testVarianceMethod · 0.45

Calls 4

meanMethod · 0.95
lengthMethod · 0.95
powMethod · 0.45
getValueMethod · 0.45

Tested by 8

testSampleAndStatsMethod · 0.76
testSampleMethod · 0.76
testSampleMethod · 0.76
testSampleMethod · 0.76
testVarianceMethod · 0.36
testVarianceMethod · 0.36
testVarianceMethod · 0.36
testVarianceMethod · 0.36