Skip to content

Commit

Permalink
ah
Browse files Browse the repository at this point in the history
  • Loading branch information
microprediction committed Mar 4, 2023
1 parent 108ccbb commit f650db1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name="winning",
version="1.0.1",
version="1.0.2",
description="Fast ability inference from contest winning probabilities",
long_description=README,
long_description_content_type="text/markdown",
Expand Down
3 changes: 1 addition & 2 deletions tests/test_state_prices_from_extended_offsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@ def assert_split_race(offsets_1, offsets_2, n_huge=1, n_inf=1, n_neg_inf=3):
offsets = offsets_1 + offsets_2 + [HUGE] * n_huge + [float('inf')] * n_inf + [float('-inf')] * n_neg_inf
prices = state_prices_from_extended_offsets(density=density, offsets=offsets, max_depth=1)


# Use a different approximation
# Use a different (poor) approximation if the second group is small
best_in_2 = min(offsets_2)
group_1 = offsets_1+[best_in_2]
# Try to approximate if we don't hit lattice issues
Expand Down
10 changes: 5 additions & 5 deletions winning/lattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ def divide_offsets(centered_offsets, max_best=20):
offset_divider = np.mean(centered_offsets) # should be 0
else:
srt_offsets = sorted(centered_offsets)
max_best = min(20, int(n/6))
max_best = min(20, int(n/6+2))
gaps = [ abs(a) for a in np.diff([srt_offsets[0]]+srt_offsets) ][:max_best] # [0, 4, 2, ...]
ndx_gap = gaps.index(max(gaps))
try:
Expand Down Expand Up @@ -682,18 +682,18 @@ def state_prices_from_extended_offsets(density, offsets, max_depth=3, unit_ratio
# Otherwise, having reached this far we have only float abilities, though some might be extremely large
L = implied_L(density)
W = int(approximate_support_width(density))
really_bad_horse_offset = min(offsets) + 2*W # <--- No chance of winning
really_bad_horse_offset = min(offsets) + W # <--- No chance of winning

# If there are really bad but finite horses, set them to float('inf') and call again
# On the next call, hopefully the centering leaves us with a tractable problem
# If there are bad but finite horses, set them to float('inf') and call again
# On the next call, hopefully the centering leaves us inside the lattice
extremely_bad_ndxs = [i for i, o in enumerate(offsets) if o > really_bad_horse_offset ]
if any(extremely_bad_ndxs):
augmented_offsets = [o if i not in extremely_bad_ndxs else float('inf') for i, o in enumerate(offsets)]
return state_prices_from_extended_offsets(density=density,
offsets=int_centered(augmented_offsets),
max_depth=max_depth)

# If there is a solitary extremely good horse, short-circuit
# If there is a solitary standout horse, short-circuit
diff_to_best = [ o - min(offsets) for o in offsets]
is_walkover = min(diff_to_best) > W*math.sqrt(len(offsets))
if is_walkover:
Expand Down

0 comments on commit f650db1

Please sign in to comment.