move comment in MeanVariance

This commit is contained in:
Jonathan J Lawlor
2014-11-14 11:05:39 -05:00
parent cbcf380d18
commit 189f14fe6e

View File

@@ -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) // \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 // If weights is nil then all of the weights are 1. If weights is not nil, then
// len(x) must equal len(weights). // 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) { 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 // note that this will panic if the slice lens do not match
u = Mean(x, weights) u = Mean(x, weights)