From 189f14fe6ecc7533b4a9ba188ace3edab5107995 Mon Sep 17 00:00:00 2001 From: Jonathan J Lawlor Date: Fri, 14 Nov 2014 11:05:39 -0500 Subject: [PATCH] move comment in MeanVariance --- stat.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/stat.go b/stat.go index 8d9c98ec..c6fd2509 100644 --- a/stat.go +++ b/stat.go @@ -912,11 +912,12 @@ func Variance(x, weights []float64) float64 { // \sum_i w_i * x_i / (sum_i w_i) and variance is \sum_i w_i (x_i - mean)^2 / (sum_i w_i - 1) // If weights is nil then all of the weights are 1. If weights is not nil, then // len(x) must equal len(weights). -// -// This uses the corrected two-pass algorithm, from "Algorithms for computing -// the sample variance: Analysis and recommendations" by Chan, Tony F., Gene H. Golub, -// and Randall J. LeVeque. func MeanVariance(x, weights []float64) (u, s2 float64) { + + // This uses the corrected two-pass algorithm (1.7), from "Algorithms for computing + // the sample variance: Analysis and recommendations" by Chan, Tony F., Gene H. Golub, + // and Randall J. LeVeque. + // note that this will panic if the slice lens do not match u = Mean(x, weights)