ts 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +20 -0
  3. data/lib/ts.rb +13 -3
  4. data/test/test_ts.rb +3 -0
  5. data/ts.gemspec +1 -0
  6. metadata +4 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 22f6b0505160ceb7fe7c019d4c101aacbd35039c
4
- data.tar.gz: 76a7f282ebfd76d98e430708d0a78ada36b4ad59
3
+ metadata.gz: ff34df04c16e070099bd33b7dc8c555e71da1ed7
4
+ data.tar.gz: 490cf55edfe90f090d8f90856bce8bf73fb72620
5
5
  SHA512:
6
- metadata.gz: cadb0aea96d5b5614455f618ca3759f6446e0dae53ece7259d851a2fbe7aa0bbef94675d2eb7ffaea53413f3468b2388aef59acae307c87c3beb72e3831dc9f0
7
- data.tar.gz: d77c9c1418a81bf0415a33b9cc0d664c8cfa32137065ee2446f3d2cccbb28f105a24d1b3647f4c4502ed4a15b3fe0182eadae22dadef8575b7fc87060b5be3d6
6
+ metadata.gz: 2a9300080f2d311dae22a4420e783747ee00b9fc4015b9b36041c314f01fff564eb4788ac0e64369b3f71880eeb4e46deae5ec59e020ed6d034b342ba4ed552e
7
+ data.tar.gz: 500647b618d9cbe60051925781980f60ca7053d6683111f3a8ce19254e6bfcc77542cef265ed998f5985f15ee623b37e43757c025d61fa6f59ae692c2279e25d
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (C) 2013 Dan Simpson
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/lib/ts.rb CHANGED
@@ -6,7 +6,7 @@
6
6
  #
7
7
  class TS
8
8
 
9
- Version = "1.0.1"
9
+ Version = "1.0.2"
10
10
 
11
11
  include Enumerable
12
12
 
@@ -88,6 +88,16 @@ class TS
88
88
  }
89
89
  end
90
90
 
91
+ # get the mean value
92
+ def mean
93
+ stats[:mean]
94
+ end
95
+
96
+ # get the standard deviation of the values
97
+ def stddev
98
+ stats[:stddev]
99
+ end
100
+
91
101
  # slice a timeseries by timestamps
92
102
  # +t1+ start time
93
103
  # +t2+ end time
@@ -181,7 +191,7 @@ class TS
181
191
  sum + (n - t_mean) ** 2
182
192
  }
183
193
 
184
- r = slope * (stddev(times) / stddev(values))
194
+ r = slope * (_stddev(times) / _stddev(values))
185
195
 
186
196
  @regression = {
187
197
  :r2 => r * r,
@@ -228,7 +238,7 @@ class TS
228
238
  end
229
239
 
230
240
  # calculate the std deviation of the 1d data set
231
- def stddev data
241
+ def _stddev data
232
242
  sum = 0.0
233
243
  sum2 = 0.0
234
244
  data.each { |v|
@@ -25,6 +25,9 @@ class TSTest < Test::Unit::TestCase
25
25
  assert_equal (1000 * (1000 + 1)) / 2, @ts.stats[:sum]
26
26
  assert_in_delta 288, @ts.stats[:stddev], 1.0
27
27
  assert_in_delta 500, @ts.stats[:mean], 1.0
28
+
29
+ assert_in_delta 288, @ts.stddev, 1.0
30
+ assert_in_delta 500, @ts.mean, 1.0
28
31
  end
29
32
 
30
33
  def test_slice
data/ts.gemspec CHANGED
@@ -4,6 +4,7 @@ require "ts"
4
4
  spec = Gem::Specification.new do |s|
5
5
  s.name = "ts"
6
6
  s.version = TS::Version
7
+ s.license = "MIT"
7
8
  s.date = "2013-08-14"
8
9
  s.summary = "Utility gem for numeric time series data"
9
10
  s.email = "dan.simpson@gmail.com"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ts
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Simpson
@@ -17,13 +17,15 @@ extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
19
  - .gitignore
20
+ - LICENSE
20
21
  - README.md
21
22
  - Rakefile
22
23
  - lib/ts.rb
23
24
  - test/test_ts.rb
24
25
  - ts.gemspec
25
26
  homepage: https://github.com/dansimpson/ts.rb
26
- licenses: []
27
+ licenses:
28
+ - MIT
27
29
  metadata: {}
28
30
  post_install_message:
29
31
  rdoc_options: []