dgaff 0.1.2 → 0.1.3
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 +8 -8
- data/lib/dgaff/array.rb +25 -0
- data/lib/dgaff/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MjAzMDVlNTg3Y2Y2MDUzMjU5OGY5ZmUyZmFhNDc2ZWZlNmIxY2RjNQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YzZiNWUxNzQ3NDNhMGE2ODM5ZTg2ZTEzNTY5NzkxMjlmOTcyNDAzNA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OWI3ODExNGQ1OWExOWRmYzlmZWU1ZmFmYjlkNzMyMDAxMjE3NWMwNTkyMDgy
|
10
|
+
NjZmMzA3ZDlkYmYyOTkxNzUyNTE3OTI0MzM4MzcwNjIwMmM0ZTMzZTQ5MzAy
|
11
|
+
NDU0OWFhZjI0ZjcwZjU3M2VhMDRlMjU2ZmI0OWYyZTlkOGVjZWQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YzMzN2E0MjUxNTI0NDRkZTQzNWZhNDU0YjUwYzBlMjE2MjBiZTY2ZWFhOGFi
|
14
|
+
MWY5OGU4NDU3MTBmYzQ4MTY4MTVkODdhYjI4OTgxNWU2OTFmZDEwMjZjNzc2
|
15
|
+
NTg3ZDljZWJjODVjMmQ2MDhjZjBkZWU0MmE4NDgxZmJjMTc0NDY=
|
data/lib/dgaff/array.rb
CHANGED
@@ -234,4 +234,29 @@ class Array
|
|
234
234
|
end
|
235
235
|
averaged
|
236
236
|
end
|
237
|
+
|
238
|
+
def elbow
|
239
|
+
elbow_cutoff
|
240
|
+
end
|
241
|
+
|
242
|
+
def elbow_cutoff
|
243
|
+
frequencies = self.counts
|
244
|
+
distances = {}
|
245
|
+
frequencies.each_pair do |insider_score, count|
|
246
|
+
translated_x = insider_score/frequencies.keys.max.to_f
|
247
|
+
translated_y = 1-insider_score/frequencies.keys.max.to_f
|
248
|
+
index = frequencies.keys.sort.index(insider_score)
|
249
|
+
expected_x = index/frequencies.length.to_f
|
250
|
+
expected_y = 1-index/frequencies.length.to_f
|
251
|
+
distances[insider_score] = Math.sqrt((translated_x-expected_x)**2+(translated_y-expected_y)**2)
|
252
|
+
end
|
253
|
+
elbow = distances.sort_by{|k,v| v}.last
|
254
|
+
return 0 if elbow.nil?
|
255
|
+
return elbow.first
|
256
|
+
end
|
257
|
+
|
258
|
+
def pareto_cutoff
|
259
|
+
#our world is a bit more unfair. 0.8 moved to 0.9.
|
260
|
+
self.percentile(0.9)
|
261
|
+
end
|
237
262
|
end
|
data/lib/dgaff/version.rb
CHANGED