tdigest 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/lib/tdigest/tdigest.rb +7 -5
- data/lib/tdigest/version.rb +1 -1
- 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: be74af8cae96393fca31017d57cd99a125c06af6
|
4
|
+
data.tar.gz: 7f17839d5f50ee56071d213c55891f189c99de37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9aa1a1379afab686402272ae6cd04a147c522d443924436cc599745abe3cf3bdf3bac86e04ef0d47428c1f8329c1a12c9789838a2b1cfae844b4b0cc089489c9
|
7
|
+
data.tar.gz: a7ceaf5fe58f37f18cd4ff5c72a026296637d73e6f7071ac9b8ed98c4c944ecbd36f7fc36d6b927e0b53102fe653688eac4c4baa013208c9e887b0e8bbf09242
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Tdigest
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/tdigest.svg)](https://badge.fury.io/rb/tdigest)
|
4
|
+
|
3
5
|
Ruby implementation of Ted Dunning's [t-digest](https://github.com/tdunning/t-digest) data structure.
|
4
6
|
|
5
7
|
Inspired by the [Javascript implementation](https://github.com/welch/tdigest) by [Will Welch](https://github.com/welch)
|
@@ -39,7 +41,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
39
41
|
|
40
42
|
## Contributing
|
41
43
|
|
42
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
44
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/castle/tdigest.
|
43
45
|
|
44
46
|
|
45
47
|
## License
|
data/lib/tdigest/tdigest.rb
CHANGED
@@ -3,6 +3,7 @@ require 'tdigest/centroid'
|
|
3
3
|
|
4
4
|
module TDigest
|
5
5
|
class TDigest
|
6
|
+
attr_accessor :centroids
|
6
7
|
def initialize(delta = 0.01, k = 25, cx = 1.1)
|
7
8
|
@delta = delta
|
8
9
|
@k = k
|
@@ -33,10 +34,10 @@ module TDigest
|
|
33
34
|
last_c = v
|
34
35
|
end
|
35
36
|
end
|
36
|
-
|
37
|
-
|
37
|
+
# If still no results, pick lagging value if any
|
38
|
+
bounds << last_c if bounds.empty? && !last_c.nil?
|
38
39
|
|
39
|
-
|
40
|
+
bounds
|
40
41
|
end
|
41
42
|
|
42
43
|
def compress!
|
@@ -102,7 +103,9 @@ module TDigest
|
|
102
103
|
_cumulate(true)
|
103
104
|
h = @n * item
|
104
105
|
lower, upper = bound_mean_cumn(h)
|
105
|
-
if
|
106
|
+
if lower.nil? && upper.nil?
|
107
|
+
nil
|
108
|
+
elsif upper == lower || lower.nil? || upper.nil?
|
106
109
|
(lower || upper).mean
|
107
110
|
elsif h == lower.mean_cumn
|
108
111
|
lower.mean
|
@@ -207,4 +210,3 @@ module TDigest
|
|
207
210
|
end
|
208
211
|
end
|
209
212
|
end
|
210
|
-
|
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.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastian Wallin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rbtree
|