correlation 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/gemspec +1 -1
- data/lib/correlation.rb +1 -2
- data/test/test_correlation.rb +9 -5
- metadata +3 -3
data/gemspec
CHANGED
data/lib/correlation.rb
CHANGED
@@ -19,7 +19,7 @@ class GSL::Vector
|
|
19
19
|
end
|
20
20
|
|
21
21
|
# predefine result vector
|
22
|
-
correlation = GSL::Vector.alloc(2*size
|
22
|
+
correlation = GSL::Vector.alloc(2*size)
|
23
23
|
|
24
24
|
# Alternate definition, which is actually the opposite direction of the definition
|
25
25
|
# (0...size).each {|i|
|
@@ -34,7 +34,6 @@ class GSL::Vector
|
|
34
34
|
(1...size).each {|i|
|
35
35
|
correlation[size+i] = (self.to_a[0...size-i].to_gv)*(other.to_a[i..size-1].to_gv.col)
|
36
36
|
}
|
37
|
-
|
38
37
|
[GSL::Vector.linspace(-size+1, size-1, 2*size-1) , correlation]
|
39
38
|
end
|
40
39
|
def autocorrelation
|
data/test/test_correlation.rb
CHANGED
@@ -8,13 +8,17 @@ class TestCorrelation < Test::Unit::TestCase
|
|
8
8
|
v = GSL::Vector.alloc([0,1,0,0,0,0,0,0,0,0])
|
9
9
|
w = GSL::Vector.alloc([0,0,0,0,0,0,0,0,1,0])
|
10
10
|
|
11
|
-
|
12
|
-
|
11
|
+
GSL::graph(v, "-X 'v' -C -g 3")
|
12
|
+
GSL::graph(w, "-X 'w' -C -g 3")
|
13
|
+
GSL::graph(v.correlation(w), "-X 'Correlation v with w' -C -g 3")
|
14
|
+
GSL::graph(v.autocorrelation,"-X 'Autocorrelation v' -C -g 3")
|
13
15
|
|
16
|
+
cor = v.correlation(w)
|
17
|
+
|
18
|
+
pp v.correlation(w)[0].to_a
|
19
|
+
pp v.correlation(w)[1].to_a
|
20
|
+
assert_equal(20,cor[1].size)
|
14
21
|
assert_equal(1, v.correlation(w)[1][-3])
|
15
22
|
assert_equal(0, v.correlation(w)[1][9])
|
16
|
-
|
17
|
-
assert_equal(1,v.autocorrelation[1][v.autocorrelation[0].where {|i| i == 0}[0]])
|
18
|
-
assert_equal(0,v.autocorrelation[1][v.autocorrelation[0].where {|i| i != 0}[0]])
|
19
23
|
end
|
20
24
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 3
|
9
|
+
version: 0.0.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Ralf Mueller
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-11-
|
17
|
+
date: 2010-11-17 22:00:27 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|