tdigest 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e55c5378cfd6bb3f02ff04c45e4a8303f2d983da
4
- data.tar.gz: 860b7f13d3d16cef3fa4b351a5e44fb56d4c987a
3
+ metadata.gz: be74af8cae96393fca31017d57cd99a125c06af6
4
+ data.tar.gz: 7f17839d5f50ee56071d213c55891f189c99de37
5
5
  SHA512:
6
- metadata.gz: 1c4883e5bbcca571dc7215fa6b5884d03fce2850e06f0892653c6285eabfaa9af54a2d0c162a5dbdc7ba32c50314aa82c44ad98bf95391dedf0ad81fd8afbc8f
7
- data.tar.gz: 7814344890f5b5d21012723f5291cb60ce0564f7792fb6e7ce0f7a9285097c636f90e0036d099ba79ac77b99346ad366f13176ee71aa6a5ad2160a5361c00949
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/[USERNAME]/tdigest. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
44
+ Bug reports and pull requests are welcome on GitHub at https://github.com/castle/tdigest.
43
45
 
44
46
 
45
47
  ## License
@@ -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
- lower = bounds[0]
37
- upper = bounds[1]
37
+ # If still no results, pick lagging value if any
38
+ bounds << last_c if bounds.empty? && !last_c.nil?
38
39
 
39
- [lower, upper]
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 upper == lower || lower.nil? || upper.nil?
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
-
@@ -1,3 +1,3 @@
1
1
  module TDigest
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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.1
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 00:00:00.000000000 Z
11
+ date: 2015-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbtree