mirror of
https://github.com/gonum/gonum.git
synced 2025-10-25 00:00:24 +08:00
change mat64.Vec to []float64
This commit is contained in:
@@ -18,7 +18,7 @@ import (
|
|||||||
// data matrix x. cov should be a square matrix with the same number of
|
// data matrix x. cov should be a square matrix with the same number of
|
||||||
// columns as the input data matrix x, or if it is nil then a new Dense
|
// columns as the input data matrix x, or if it is nil then a new Dense
|
||||||
// matrix will be constructed.
|
// matrix will be constructed.
|
||||||
func CovarianceMatrix(cov *mat64.Dense, x mat64.Matrix, wts mat64.Vec) *mat64.Dense {
|
func CovarianceMatrix(cov *mat64.Dense, x mat64.Matrix, wts []float64) *mat64.Dense {
|
||||||
|
|
||||||
// matrix version of the two pass algorithm. This doesn't use
|
// matrix version of the two pass algorithm. This doesn't use
|
||||||
// the correction found in the Covariance and Variance functions.
|
// the correction found in the Covariance and Variance functions.
|
||||||
@@ -50,7 +50,7 @@ func CovarianceMatrix(cov *mat64.Dense, x mat64.Matrix, wts mat64.Vec) *mat64.De
|
|||||||
// normalization factor, typical n-1
|
// normalization factor, typical n-1
|
||||||
var N float64
|
var N float64
|
||||||
if wts != nil {
|
if wts != nil {
|
||||||
if wr, _ := wts.Dims(); wr != r {
|
if wr := len(wts); wr != r {
|
||||||
panic("weight vector length mismatch")
|
panic("weight vector length mismatch")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,13 +47,13 @@ func TestCovarianceMatrix(t *testing.T) {
|
|||||||
1, -2,
|
1, -2,
|
||||||
2, 4,
|
2, 4,
|
||||||
}),
|
}),
|
||||||
weights: mat64.Vec([]float64{
|
weights: []float64{
|
||||||
1.5,
|
1.5,
|
||||||
.5,
|
.5,
|
||||||
1.5,
|
1.5,
|
||||||
.5,
|
.5,
|
||||||
1,
|
1,
|
||||||
}),
|
},
|
||||||
r: 2,
|
r: 2,
|
||||||
c: 2,
|
c: 2,
|
||||||
x: []float64{
|
x: []float64{
|
||||||
|
|||||||
Reference in New Issue
Block a user