tiny_outcome 1.0.1 → 2.0.0

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 +5 -38
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: abde8e389e945ae56753b61b75b9f7df7474044820cff7250874a73286a2f8bb
4
- data.tar.gz: 59f041591c740d22a42f55ef7e6a2363854d9715a4aa22775fb80f8384836aee
3
+ metadata.gz: ebffbf581a411eb6ff64bd292e95cbb41e8ed3e99992013c89cd503d90105777
4
+ data.tar.gz: f7073aa9eabe6a1d969d1aae133a96cfc0b3064300ec47f53b5649a3f0c97abd
5
5
  SHA512:
6
- metadata.gz: b6c89f18a20e5b2c4e0b0fbaff9391680b98901a6f2ee6cfc6af09089027c9b9642fafb28ea46c46ec7af42282c083a3fc98477413ea3510ed2d072764a4200f
7
- data.tar.gz: ec5e0b226364e2d8f7810fa9fd4691acb8fc3dae2dc704c9566ba0d27c05f571252b14b47d5d077a646927a5c31869356b7f0a6145ca3b2b20ecb5178581d574
6
+ metadata.gz: 43736cd94727be0fe53354e21d9018d63ff14bc7787891460e81b590b8320aa637a20975663c10b318ca42f033baaefc44f7cbcffba4b0c542ef79a97ac634fb
7
+ data.tar.gz: db0da73385a7d80b91b750fd29123ffbc3b7f2df2a3753e0b4895dc28a0dc59767fcdce7e43d7e496d4b7a8644307a685cc376ffa743cb5a6480d2d0da074708
data/lib/tiny_outcome.rb CHANGED
@@ -20,17 +20,11 @@
20
20
  # 87.times { o << rand(2) }
21
21
  #
22
22
  # to_s reveals how we're doing:
23
- # L10 1111000110 coinflip 0.49 84/84::128/128
23
+ # L10 1111000110 w 0.49 84/84::128/128
24
24
  #
25
25
  # this tells us that of the 128 precision capacity, we're currently warmed up
26
- # because we have the minimum (at least 84 samples) to be considered warmed up.
27
- # there's also a prediction here: that the outcome is essentially a coinflip.
28
- # this is because the observed likelihood of an outcome of 1 is 49% in this
29
- # example, well within the range of random chance. if we had a TinyOutcome with
30
- # a precision of 10,000 we wouldn't necessarily consider 49% a true coinflip,
31
- # but because we're trying to predict things within a relatively small sample
32
- # size, we don't want to go all the way to that level of precision, it's more
33
- # like just trying to win more than we lose.
26
+ # because we have the minimum (at least 84 samples) to be considered warmed up
27
+ # (this is also indicated with the lowercase 'w').
34
28
  class TinyOutcome
35
29
  attr_reader :precision,
36
30
  :samples,
@@ -95,33 +89,6 @@ class TinyOutcome
95
89
  value.to_s(2).count('1') / samples.to_f
96
90
  end
97
91
 
98
- # classifies the probability of the next outcome
99
- #
100
- # :cold - if this Outcome isn't yet warm
101
- # :highly_positive - greater than 95% chance that the next outcome will be a 1
102
- # :positive - greater than 90% chance the next outcome will be a 1
103
- # :coinflip - 50% chance (+/- 5%) that the next outcome will be a 1
104
- # :negative - less than 10% chance the next outcome will be a 1
105
- # :highly_negative - less than 5% chance the next outcome will be a 1
106
- # :weak - for all other outcomes
107
- def prediction
108
- return :cold unless warm?
109
-
110
- case probability
111
- when 0...0.05 then :disaster
112
- when 0.05...0.1 then :strongly_negative
113
- when 0.1...0.32 then :negative
114
- when 0.32..0.34 then :one_third
115
- when 0.34...0.48 then :weakly_negative
116
- when 0.48..0.52 then :coinflip
117
- when 0.52...0.65 then :weakly_positive
118
- when 0.65..0.67 then :two_thirds
119
- when 0.67..0.9 then :positive
120
- when 0.9...0.95 then :strongly_positive
121
- when 0.95..1.0 then :amazing
122
- end
123
- end
124
-
125
92
  # true if we've received at least warmup number of samples
126
93
  # false otherwise
127
94
  def warm?
@@ -146,15 +113,15 @@ class TinyOutcome
146
113
  :warmth,
147
114
  :warmup,:warm?,
148
115
  :probability,
149
- :prediction,
150
116
  ].each_with_object({}) do |attr, memo|
151
117
  memo[attr] = send(attr)
152
118
  memo
153
119
  end
154
120
  end
155
121
 
122
+ # L10 = last 10 samples
156
123
  def to_s
157
124
  max_backward = [value.to_s(2).length, 10].min
158
- "L10 #{value.to_s(2)[-max_backward..-1].rjust(10, '?')} #{prediction} #{'%.2f' % probability} #{warmth}/#{warmup}::#{samples}/#{precision}"
125
+ "L10 #{value.to_s(2)[-max_backward..-1].rjust(10, '?')} #{warm? ? 'w' : 'c'} #{'%.2f' % probability} #{warmth}/#{warmup}::#{samples}/#{precision}"
159
126
  end
160
127
  end
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: 1.0.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Lunt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-04 00:00:00.000000000 Z
11
+ date: 2022-12-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: a tiny outcome tracker with almost no features
14
14
  email: jefflunt@gmail.com