### Question:
DoubleVertexSamples extends Samples<DoubleTensor> { public DoubleTensor getVariances() { DoubleTensor sumOfSquares = this.samples.stream() .reduce(DoubleTensor.zeros(sampleShape), (l, r) -> l.plusInPlace(r.pow(2))); return sumOfSquares .divInPlace((double) samples.size()) .minusInPlace(getAverages().pow(2)) .timesInPlace((double) samples.size()) .divInPlace(samples.size() - 1.); } DoubleVertexSamples(List<DoubleTensor> samples); DoubleTensor getAverages(); DoubleTensor getVariances(); DoubleTensor getAutocorrelation(long... index); @Override DoubleTensor asTensor();  }### Answer:
@Test public void doesCalculateVariance() { DoubleTensor variances = samples.getVariances(); DoubleTensor expectedValues = DoubleTensor.create( stats.stream().mapToDouble(SummaryStatistics::getVariance).toArray() ); assertThat(variances, allCloseTo(1e-8, expectedValues)); }