public
Description: New development on the Ruby bindings for the GNU Scientific Library
Clone URL: git://github.com/codahale/ruby-gsl.git
Added Tanimoto coefficient into Array.
codahale (author)
Mon Feb 25 19:40:46 -0800 2008
commit  f6687744c7ee4efc4f99148110febc0e7814c54d
tree    2215f5b191c655a44f7a451d249b738c46fc8899
parent  00ae5e36e32b0f70acb383281a2082cad0220bea
...
5
6
7
8
 
9
10
11
 
12
13
14
15
 
16
17
18
19
 
20
21
 
 
 
 
 
 
22
23
24
...
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
0
@@ -5,19 +5,27 @@ class Array
0
     if size == y.size
0
       return GSL::Stats.correlation1(self, y)
0
     else
0
- raise ArgumentError, "cannot correlated two differently-sized arrays"
0
+ raise ArgumentError, "cannot correlate two differently-sized arrays"
0
     end
0
   end
0
   
0
+ # Returns the arithmetic mean of the elements of the array.
0
   def mean
0
     return GSL::Stats.mean1(self)
0
   end
0
   
0
+ # Returns the variance of the elements of the array.
0
   def variance
0
     return GSL::Stats.variance1(self)
0
   end
0
   
0
+ # Returns the standard distribution of the elements of the array.
0
   def sd
0
- return GSL::Stats::sd1(self)
0
+ return GSL::Stats.sd1(self)
0
+ end
0
+
0
+ # Returns the Tanimoto coefficient of the array and +y+.
0
+ def tanimoto_coefficient(y)
0
+ return GSL::Similarity.tanimoto_coefficient(self, y)
0
   end
0
 end
0
\ No newline at end of file
...
30
31
32
 
 
 
 
 
 
 
33
34
...
30
31
32
33
34
35
36
37
38
39
40
41
0
@@ -30,4 +30,11 @@ describe Array do
0
       [2, 2, 2].sd.should be_close(0.0, 0.0001)
0
     end
0
   end
0
+
0
+ describe "calculating the Tanimoto coefficient" do
0
+ it "should return a real number" do
0
+ [1, 2, 3].tanimoto_coefficient([1, 2, 3]).should be_close(1.0, 0.0001)
0
+ [1, 2, 3].tanimoto_coefficient([4, 5, 6]).should be_close(0.0, 0.0001)
0
+ end
0
+ end
0
 end
0
\ No newline at end of file

Comments

    No one has commented yet.