tiny_outcome 1.0.0 → 2.0.0
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 +4 -4
- data/lib/tiny_outcome.rb +10 -38
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ebffbf581a411eb6ff64bd292e95cbb41e8ed3e99992013c89cd503d90105777
|
4
|
+
data.tar.gz: f7073aa9eabe6a1d969d1aae133a96cfc0b3064300ec47f53b5649a3f0c97abd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
-
#
|
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,39 +89,17 @@ 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?
|
128
95
|
warmth == warmup
|
129
96
|
end
|
130
97
|
|
98
|
+
# the opposite of warm: a TinyOutcome can only be cold or warm
|
99
|
+
def cold?
|
100
|
+
!warm?
|
101
|
+
end
|
102
|
+
|
131
103
|
# true if we've received at least precision number of samples
|
132
104
|
# false otherwise
|
133
105
|
def full?
|
@@ -141,15 +113,15 @@ class TinyOutcome
|
|
141
113
|
:warmth,
|
142
114
|
:warmup,:warm?,
|
143
115
|
:probability,
|
144
|
-
:prediction,
|
145
116
|
].each_with_object({}) do |attr, memo|
|
146
117
|
memo[attr] = send(attr)
|
147
118
|
memo
|
148
119
|
end
|
149
120
|
end
|
150
121
|
|
122
|
+
# L10 = last 10 samples
|
151
123
|
def to_s
|
152
124
|
max_backward = [value.to_s(2).length, 10].min
|
153
|
-
"L10 #{value.to_s(2)[-max_backward..-1].rjust(10, '?')} #{
|
125
|
+
"L10 #{value.to_s(2)[-max_backward..-1].rjust(10, '?')} #{warm? ? 'w' : 'c'} #{'%.2f' % probability} #{warmth}/#{warmup}::#{samples}/#{precision}"
|
154
126
|
end
|
155
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:
|
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-
|
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
|