tiny_outcome 3.1.0 → 3.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tiny_outcome.rb +9 -9
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7e887122fe969136656c57bf1e8a240df3500f0120694891be4f9ba26cf9c694
4
- data.tar.gz: 92e30c4c3c72afc4942181ede0badc1865b297c0444a1c7ec7cce272e4a7dac8
3
+ metadata.gz: c42e1143dcbebc9e17795c5972896594ca2efd105efb6dc57c6994396e2f50a9
4
+ data.tar.gz: ff222da29f706b0c362b8f6901a10efaf6df4428ee18414e709fc2f9722b94f2
5
5
  SHA512:
6
- metadata.gz: 31bf45e93abd24309b440599f7006573dd6b2beb19a588234b6f15aaed4334bde062b252f8bdecf2a7f8b72fe3a42def7a55d38a225b8e37cb19af2dfc375977
7
- data.tar.gz: b828c61ee05e08de9041bdb5b17a95005ef2cf315419bd3806dc9feec2efb5ba2138231bd8ff9d4bc74e5d02079848c4356d0dc779d02709a12623cccc6ce66d
6
+ metadata.gz: a8059baa7359247f5c60198d517c8e5d3e05706c75e54347068788f450ea6bf0d438db7ae8c05df7264aaab48083697953e3d13c0f8795d2215b080c1ad3fb26
7
+ data.tar.gz: e04fbe290c68b7d1226f02cda213044cf0fd0c24784a1359404133b1895d099ff5eae1192d113231ae0ba71fa920d191dd2e8cf2179b5eb2bb6c8e51b02c4b08
data/lib/tiny_outcome.rb CHANGED
@@ -52,9 +52,9 @@ class TinyOutcome
52
52
  @probability = 0.0
53
53
  @one_count = 0
54
54
  @samples = 0
55
- @min = -1.0
56
- @max = -1.0
57
- @avg = -1.0
55
+ @min = 1.0
56
+ @max = 0.0
57
+ @avg = 0.0
58
58
  @warmth = 0
59
59
  @value = [0] * @precision
60
60
  @value_index = 0
@@ -132,16 +132,16 @@ class TinyOutcome
132
132
  sum = 0.0
133
133
  raw = (full? ? @value.rotate(@value_index) : @value)[..(samples-1)]
134
134
  group_size = [@samples, 100].min
135
- num_groups = @samples - group_size
135
+ num_groups = (@samples - group_size) + 1
136
136
  raw.each_cons(group_size) do |samples_group|
137
- curr = samples_group.count(1) / samples.to_f
138
- sum += curr
137
+ num_ones = samples_group.count(1) / group_size.to_f
138
+ sum += num_ones
139
139
 
140
- @min = curr if curr < @min
141
- @max = curr if curr > @max
140
+ @min = num_ones if num_ones < @min
141
+ @max = num_ones if num_ones > @max
142
142
  end
143
143
 
144
- @avg = sum / (@num_groups.to_f + 1.0)
144
+ @avg = sum / num_groups.to_f
145
145
  end
146
146
 
147
147
  # convenient way to see what's up
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tiny_outcome
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Lunt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-28 00:00:00.000000000 Z
11
+ date: 2023-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest