pdist 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/pdist.rb +6 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60af35948ee406fc8869882d08b86638d9d451ae
|
4
|
+
data.tar.gz: b03e2749c3e332d2348e9d960fbcb944be1195ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cde3314e504ce289b30b271e584aef46a9026a8281e69469b4e5786ba769092d649aa2170028bbd2d0ea2b499f09332e0026aecc89a1a89a90869f906f380a71
|
7
|
+
data.tar.gz: bebfc1d120e68ecd67a93b736fdc7276eac1e8e3c958887efee64893cc848993fbc77cddb5662617000727b23c9ae91eac1ecd1147e1cfe98d531490b0a971fc
|
data/lib/pdist.rb
CHANGED
@@ -37,8 +37,8 @@ class PDist
|
|
37
37
|
def self.hamming(original, permutation)
|
38
38
|
x = 0
|
39
39
|
hds = [] # hamming distances
|
40
|
-
permutation.each do |
|
41
|
-
if
|
40
|
+
permutation.each do |object| # hamming distances are 0 when object's have same index in original and permutation, and 1 when not
|
41
|
+
if object == original[x]
|
42
42
|
hds << 0
|
43
43
|
else
|
44
44
|
hds << 1
|
@@ -77,11 +77,11 @@ class PDist
|
|
77
77
|
n = permutation.length
|
78
78
|
x = 0
|
79
79
|
kt = []
|
80
|
-
|
80
|
+
original.each do |original_x| # for each of the objects in original...
|
81
81
|
y = 0
|
82
|
-
n.times do
|
83
|
-
if
|
84
|
-
kt << 1
|
82
|
+
n.times do # ... iterate over both original and permutation
|
83
|
+
if original_x < original[y] && permutation[x] > permutation[y] # every time object y comes before object x in permutation, where it comes after in original...
|
84
|
+
kt << 1 # ... 1 is added
|
85
85
|
else
|
86
86
|
kt << 0
|
87
87
|
end
|
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: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edward Chalstrey
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-01 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'
|