pdist 0.0.1 → 0.0.2

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pdist.rb +4 -14
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 93d5f87c7a83d4e003d7ef317cf5ae54335c6fdc
4
- data.tar.gz: f4ff97880bfe111e17ee7fb32731540663eae20a
3
+ metadata.gz: 1ab14b4afc32f4446b586db088d314b4e0a75bac
4
+ data.tar.gz: 38596c57ac1bd79f64cf24a47cee4e06c37ca23c
5
5
  SHA512:
6
- metadata.gz: 235ba5edeb10e13199da46ae580d88c4b550381c19887b657750af2e824c99ba16cc951f5a71162177e948ec25b62f1f536b3b8ffa589db2b311cd567402f9d0
7
- data.tar.gz: 3ff4d9ea7d2f9a14fab4370b9959e3dc542a38b8ff39c9f8873c09f3fd207a843593aff9aa1ccd6bbb9436b32abc0403955c6738e1ae4e7135816ff7bf085380
6
+ metadata.gz: 8e5417f94da5b7247bddc96c61d1fd70bb106f1efb5f3a850c34b359b64d76c59ea97788611c31ad4adb716ce08f7b792f7600d78b482d133f8dacf5a984083f
7
+ data.tar.gz: 6bbb082ee9a403f7db62ac373e7dbb9cb593a02cb970a575135c7a909ad595205334354f1bb0af06f172ee57a70e6cf4556252d8a389b3befc329b6257108a48
@@ -12,7 +12,7 @@ class PDist
12
12
  return difference_abs
13
13
  end
14
14
 
15
- def self.dev_dist(original, permutation)
15
+ def self.deviation(original, permutation)
16
16
  s = distances(original, permutation).inject(:+)
17
17
  n = permutation.length
18
18
  if n % 2 == 0
@@ -23,7 +23,7 @@ class PDist
23
23
  return score
24
24
  end
25
25
 
26
- def self.sq_dev_dist(original, permutation)
26
+ def self.square(original, permutation)
27
27
  sq_dists = []
28
28
  distances(original, permutation).each{|d| sq_dists << d**2}
29
29
  s = sq_dists.inject(:+)
@@ -45,21 +45,11 @@ class PDist
45
45
  return hds.inject(:+)
46
46
  end
47
47
 
48
- def self.gen_ham_dist(original, permutation)
48
+ def self.hamming(original, permutation) # generalized hamming distance
49
49
  ham_dist(original, permutation).to_f / permutation.length.to_f # normalize by dividing by the max score, which == number of objects
50
50
  end
51
51
 
52
- def self.mod_ham_dist(original, permutation)
53
- pos_1 = permutation.index(original[0]) # position of the first object of original order in permutation
54
- if original[0] != permutation[0]
55
- new_a = [permutation[pos_1..-1], permutation[0..pos_1-1]].flatten # re-order the permutation to get first object at front
56
- else
57
- new_a = permutation # running the if above for a permutation with 1 at front results in duplicates
58
- end
59
- return (ham_dist(original, new_a) + pos_1).to_f / (2 * (permutation.length - 1)).to_f # no need to take away 1 from pos_1 as the index in ruby is position - 1
60
- end
61
-
62
- def self.r_dist(original, permutation) # reverse R distance (since higher scores = bad)
52
+ def self.rdist(original, permutation) # reverse R distance (since higher scores = bad)
63
53
  x = 0
64
54
  r = []
65
55
  n = permutation.length
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pdist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edward Chalstrey