comment for source of covariance algo

This commit is contained in:
Jonathan J Lawlor
2014-11-14 00:07:45 -05:00
parent 530d3d8d07
commit a766f2b2b7

View File

@@ -187,10 +187,9 @@ func Correlation(x, y, weights []float64) float64 {
// The lengths of x and y must be equal. If weights is nil then all of the // The lengths of x and y must be equal. If weights is nil then all of the
// weights are 1. If weights is not nil, then len(x) must equal len(weights). // weights are 1. If weights is not nil, then len(x) must equal len(weights).
func Covariance(x, y, weights []float64) float64 { func Covariance(x, y, weights []float64) float64 {
// This is a two-pass corrected implementation. It is an adaptation of the
// don't have a paper for this, but the unweighted adaptation seems natural. // algorithm used in the MeanVariance function, which applies a correction
// The weighted version doesn't perform a correction. It seemed like the // to the typical two pass approach.
// performance would suffer too much.
if len(x) != len(y) { if len(x) != len(y) {
panic("stat: slice length mismatch") panic("stat: slice length mismatch")