pdist 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pdist.rb +8 -3
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7658e7014e754f6e581a508298e1454555918b62
|
4
|
+
data.tar.gz: a733aa5b38427addeb511edc1cfd7bbda1256f36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1854675efd40fb379c11c71db9287cd85841a928f13352a2e6629cb5dd34d647c8c43bfb6a410c566da9062ab7c1eb793906f49fee5fbf452fdaa8b7347d7a7e
|
7
|
+
data.tar.gz: e2dfba170eefde76fb56ce2948b5379b450ecd6a7a5041f4811a0a209523e664c7aec111ea25976900561e17020c9e95fd7463f260fa9783bb9d9c56147c15e9
|
data/lib/pdist.rb
CHANGED
@@ -84,13 +84,13 @@ class PDist
|
|
84
84
|
|
85
85
|
# Returns float of the longest common sub-sequence between original and permutation
|
86
86
|
def self.lcs_raw(original, permutation)
|
87
|
-
return Diff::LCS.LCS(original, permutation) # diff-lcs gem used to calculate longest common sub-sequence
|
87
|
+
return Diff::LCS.LCS(original, permutation).length # diff-lcs gem used to calculate longest common sub-sequence
|
88
88
|
end
|
89
89
|
|
90
90
|
# Returns float of the longest common sub-sequence between original and permutation, normalized between 0.0 and 1.0
|
91
91
|
def self.lcs(original, permutation)
|
92
92
|
lcs = lcs_raw(original, permutation)
|
93
|
-
return (permutation.length - lcs
|
93
|
+
return (permutation.length - lcs).to_f / (permutation.length - 1).to_f # normalized: dividing by longest possible common sub-sequence
|
94
94
|
end
|
95
95
|
|
96
96
|
# Returns float of the kendall's tau distance between original and permutation
|
@@ -104,7 +104,12 @@ class PDist
|
|
104
104
|
end
|
105
105
|
end
|
106
106
|
end
|
107
|
-
|
107
|
+
tau = kt.inject(:+)
|
108
|
+
unless tau == nil
|
109
|
+
return kt.inject(:+) # the number of pairwise adjacent permutations required to transform original into permutation
|
110
|
+
else
|
111
|
+
return 0
|
112
|
+
end
|
108
113
|
end
|
109
114
|
|
110
115
|
# Returns float of the kendall's tau distance between original and permutation, normalized between 0.0 and 1.0
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pdist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edward Chalstrey
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: 'Ruby gem to compare permutations using distance measures/metrics. github:
|
14
14
|
https://github.com/edwardchalstrey1/pdist'
|
@@ -28,17 +28,17 @@ require_paths:
|
|
28
28
|
- lib
|
29
29
|
required_ruby_version: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
35
|
requirements:
|
36
|
-
- -
|
36
|
+
- - ">="
|
37
37
|
- !ruby/object:Gem::Version
|
38
38
|
version: '0'
|
39
39
|
requirements: []
|
40
40
|
rubyforge_project:
|
41
|
-
rubygems_version: 2.
|
41
|
+
rubygems_version: 2.4.7
|
42
42
|
signing_key:
|
43
43
|
specification_version: 4
|
44
44
|
summary: Permutation distance metrics
|