tdigest 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -2
- data/lib/tdigest/centroid.rb +5 -4
- data/lib/tdigest/tdigest.rb +8 -11
- data/lib/tdigest/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5aeae6aa49816daeea269ec499590c97075a3149
|
4
|
+
data.tar.gz: dd214c32109be62d1fb145743f52d1398feb13d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cc95403c4e428cf3ea0443e0cda972dd78b948779bff3fccf6265c155a50d47d83489965e93aa9ef6dbee316d543107d36a9fe76bbf5b8ea76f034d3f7332c4
|
7
|
+
data.tar.gz: 1325bf0d452da07415d9a12aabf8e014c76c7ade0ab21615cf95bfb4f582d9373b4b7ba70d6265a19d449ae9f88e45d6e1c52624c82d73e96f0f8bfaf4db5678
|
data/.travis.yml
CHANGED
data/lib/tdigest/centroid.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
module TDigest
|
2
2
|
class Centroid
|
3
3
|
attr_accessor :mean, :n, :cumn, :mean_cumn
|
4
|
-
def initialize(
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
def initialize(mean, n, cumn, mean_cumn = nil)
|
5
|
+
@mean = mean
|
6
|
+
@n = n
|
7
|
+
@cumn = cumn
|
8
|
+
@mean_cumn = mean_cumn
|
8
9
|
end
|
9
10
|
|
10
11
|
def as_json(_ = nil)
|
data/lib/tdigest/tdigest.rb
CHANGED
@@ -13,6 +13,7 @@ module TDigest
|
|
13
13
|
@cx = cx
|
14
14
|
@centroids = RBTree.new
|
15
15
|
@nreset = 0
|
16
|
+
@n = 0
|
16
17
|
reset!
|
17
18
|
end
|
18
19
|
|
@@ -97,10 +98,8 @@ module TDigest
|
|
97
98
|
def compress!
|
98
99
|
points = to_a
|
99
100
|
reset!
|
100
|
-
|
101
|
-
|
102
|
-
end
|
103
|
-
_cumulate(true)
|
101
|
+
push_centroid(points.shuffle)
|
102
|
+
_cumulate(true, true)
|
104
103
|
nil
|
105
104
|
end
|
106
105
|
|
@@ -128,10 +127,8 @@ module TDigest
|
|
128
127
|
end
|
129
128
|
|
130
129
|
def merge!(other)
|
131
|
-
|
132
|
-
|
133
|
-
@centroids = t.centroids
|
134
|
-
compress!
|
130
|
+
push_centroid(other.centroids.values.shuffle)
|
131
|
+
self
|
135
132
|
end
|
136
133
|
|
137
134
|
def p_rank(x)
|
@@ -277,7 +274,6 @@ module TDigest
|
|
277
274
|
nearest.cumn += n
|
278
275
|
nearest.mean_cumn += n / 2.0
|
279
276
|
nearest.n += n
|
280
|
-
@n += n
|
281
277
|
|
282
278
|
nil
|
283
279
|
end
|
@@ -311,6 +307,8 @@ module TDigest
|
|
311
307
|
max = max.nil? ? nil : max[1]
|
312
308
|
nearest = find_nearest(x)
|
313
309
|
|
310
|
+
@n += n
|
311
|
+
|
314
312
|
if nearest && nearest.mean == x
|
315
313
|
_add_weight(nearest, x, n)
|
316
314
|
elsif nearest == min
|
@@ -341,9 +339,8 @@ module TDigest
|
|
341
339
|
end
|
342
340
|
|
343
341
|
def _new_centroid(x, n, cumn)
|
344
|
-
c = Centroid.new(
|
342
|
+
c = Centroid.new(x, n, cumn)
|
345
343
|
@centroids[x] = c
|
346
|
-
@n += n
|
347
344
|
c
|
348
345
|
end
|
349
346
|
end
|
data/lib/tdigest/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tdigest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastian Wallin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rbtree
|
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
135
|
version: '0'
|
136
136
|
requirements: []
|
137
137
|
rubyforge_project:
|
138
|
-
rubygems_version: 2.
|
138
|
+
rubygems_version: 2.5.1
|
139
139
|
signing_key:
|
140
140
|
specification_version: 4
|
141
141
|
summary: Ruby implementation of Dunning's T-Digest for streaming quantile approximation
|