-
Notifications
You must be signed in to change notification settings - Fork 2
/
correlation_test.go
66 lines (53 loc) · 1.35 KB
/
correlation_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package gdsp
import (
"testing"
)
func TestXCorr1(t *testing.T) {
u := MakeVectorFromArray([]float64{1.0, 2.0, 3.0})
v := MakeVectorFromArray([]float64{1.0})
xCorr := XCorr(u, v)
if !xCorr.IsCloseToVector(u, 0.00001) {
t.Fail()
}
}
func TestXCorr2(t *testing.T) {
u := MakeVectorFromArray([]float64{1.0, 2.0, 3.0})
v := MakeVectorFromArray([]float64{1.0, 2.0})
ex := MakeVectorFromArray([]float64{5.0, 8.0, 3.0, 0.0})
xCorr := XCorr(u, v)
if !xCorr.IsCloseToVector(ex, 0.00001) {
t.Fail()
}
}
func TestXCorr3(t *testing.T) {
u := MakeVectorFromArray([]float64{1.0, 2.0, 3.0})
v := MakeVectorFromArray([]float64{1.0, 2.0, 3.0})
ex := MakeVectorFromArray([]float64{14.0, 8.0, 3.0, 0.0, 3.0})
conv := XCorr(u, v)
if !conv.IsCloseToVector(ex, 0.00001) {
t.Fail()
}
}
func TestACorr1(t *testing.T) {
v := MakeVectorFromArray([]float64{1.0})
aCorr := ACorr(v)
if !aCorr.IsCloseToVector(v, 0.00001) {
t.Fail()
}
}
func TestACorr2(t *testing.T) {
v := MakeVectorFromArray([]float64{1.0, 2.0})
ex := MakeVectorFromArray([]float64{5.0, 2.0, 0.0})
aCorr := ACorr(v)
if !aCorr.IsCloseToVector(ex, 0.00001) {
t.Fail()
}
}
func TestACorr3(t *testing.T) {
v := MakeVectorFromArray([]float64{1.0, 2.0, 3.0})
ex := MakeVectorFromArray([]float64{14.0, 8.0, 3.0, 0.0, 3.0})
aCorr := ACorr(v)
if !aCorr.IsCloseToVector(ex, 0.00001) {
t.Fail()
}
}