tiny_outcome 3.1.2 → 3.2.0
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 +15 -1
- 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: 222afbe6c83b56651c435d5359c27eee5f0e6eba0692ebfb6fdce8e7754b7702
|
4
|
+
data.tar.gz: ede91ff6d13e6e978a61780f0a1f9c9bb4e76451bbff21c3b6c30ed666722265
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d309251961ce51a7c4424019a654df5ff5b0a29bf7be56e6b16c87330dc6f56137cc991e0b6bf49e6757656fdac72a4c06fdb463a605971a8df9b313d6364232
|
7
|
+
data.tar.gz: 1f3c55cbf2c1d189e8fe28aaa464a6652515b9902921a548cfccb5731e39c7bcad128ebfc3c854fdc245748862fb4a33edded6169c9e7eeccf8d3c3663307c8d
|
data/lib/tiny_outcome.rb
CHANGED
@@ -70,8 +70,14 @@ class TinyOutcome
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
+
# returns the array of collected samples of 1s and 0s
|
74
|
+
def collected_samples
|
75
|
+
(full? ? @value.rotate(@value_index) : @value)[..(samples-1)]
|
76
|
+
end
|
77
|
+
|
78
|
+
# converts the array of #collected_samples to a base-10 Integer
|
73
79
|
def numeric_value
|
74
|
-
|
80
|
+
collected_samples.join.to_i(2)
|
75
81
|
end
|
76
82
|
|
77
83
|
# add a sample to the historic outcomes
|
@@ -103,6 +109,14 @@ class TinyOutcome
|
|
103
109
|
@probability >= percentage
|
104
110
|
end
|
105
111
|
|
112
|
+
# true if #probability is >= percentage
|
113
|
+
# false otherwise
|
114
|
+
def winner_at_lately?(percentage, max_samples)
|
115
|
+
recent_samples = collected_samples.last(max_samples)
|
116
|
+
recent_probability = recent_samples.count(1) / recent_samples.length.to_f
|
117
|
+
recent_probability >= percentage
|
118
|
+
end
|
119
|
+
|
106
120
|
# true if we've received at least warmup number of samples
|
107
121
|
# false otherwise
|
108
122
|
def warm?
|
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.
|
4
|
+
version: 3.2.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: 2023-11-
|
11
|
+
date: 2023-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|