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 CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
 
3
3
  spec = Gem::Specification.new do |s|
4
4
  s.name = 'correlation'
5
- s.version = '0.0.2'
5
+ s.version = '0.0.3'
6
6
  s.date = Time.new.to_s
7
7
  s.author = 'Ralf Mueller'
8
8
  s.email = 'stark.dreamdetective@gmail.com'
@@ -19,7 +19,7 @@ class GSL::Vector
19
19
  end
20
20
 
21
21
  # predefine result vector
22
- correlation = GSL::Vector.alloc(2*size+1)
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
@@ -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
- #GSL::graph(v.correlation(w), "-X 'Correlation v with w' -C -g 3")
12
- #GSL::graph(v.autocorrelation,"-X 'Autocorrelation v' -C -g 3")
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
- - 2
9
- version: 0.0.2
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-16 00:36:11 +01:00
17
+ date: 2010-11-17 22:00:27 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency