tiny_outcome 1.0.1 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tiny_outcome.rb +9 -42
- 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: 3611d8970ea3a209328e2149c518dc2c8ea0e15c8297ec6951d63c0d2c9d2ce1
|
4
|
+
data.tar.gz: 0bb76d7481157879e2d7a4e0b0d3edfc87bb96af5a85c5c3dc64187e9b53c6af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10d7cea58b4f4bdf02988ff2ab3fcb91ee3f28dea1df19ddaa2e0fff2d3f7090e39dd4f696985926e688ae320128dab7d96708aee3f87c3cb8bff026d075c353
|
7
|
+
data.tar.gz: 5646f503b6998e99df4d68e21a10f70344d3e9e9f0aa363e9b751d2def1664924a286319c022867fc0019cce5f2f40ee74b0792bf18ef67c156af88681805da8
|
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,
|
@@ -60,7 +54,8 @@ class TinyOutcome
|
|
60
54
|
when WARM_ONE_THIRD then precision / 3
|
61
55
|
when WARM_NONE then 0
|
62
56
|
else
|
63
|
-
raise "Invalid warmup: #{warmup.inspect}"
|
57
|
+
raise "Invalid warmup: #{warmup.inspect}" if (!warmup.is_a?(Integer) || warmup < 1)
|
58
|
+
warmup
|
64
59
|
end
|
65
60
|
end
|
66
61
|
|
@@ -91,41 +86,13 @@ class TinyOutcome
|
|
91
86
|
# probabilty = ---------------
|
92
87
|
# total samples
|
93
88
|
def probability
|
94
|
-
|
95
|
-
value.to_s(2).count('1') / samples.to_f
|
96
|
-
end
|
97
|
-
|
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
|
89
|
+
(value.to_s(2).count('1') / samples.to_f).round(2)
|
123
90
|
end
|
124
91
|
|
125
92
|
# true if we've received at least warmup number of samples
|
126
93
|
# false otherwise
|
127
94
|
def warm?
|
128
|
-
warmth
|
95
|
+
warmth >= warmup
|
129
96
|
end
|
130
97
|
|
131
98
|
# the opposite of warm: a TinyOutcome can only be cold or 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, '?')} #{
|
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:
|
4
|
+
version: 2.0.1
|
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-30 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
|