| I have written some single threaded non-simd c++ code for this :
https://gist.github.com/unrealwill/d1bc68d1f5c7ee6fe72b76dc5... When there are 14 matches, there are 3^14 = 4782969 different possible results and the same number of different possible bets. Summing naively a single expectation takes 0.1s
Summing on the hamming neighborhood to compute a single expectation takes 7.6e-5s, Computing all expectation values and computing the maximum takes 153s (with g++9 but 390s with g++-10 (I don't know why)). I am not sure whether or not I used the same trick as you. Here are the tricks I use : when probabilities sum to one, the number of iteration to compute a single expectation is not dependent of the number of possible results for a match, because the sum can be factored by grouping all negative results for a single event together by applying the weight as 1-proba. Some tricks used are representing the result for the 14 matches as a single int32_t and working in base 3. It can probably be even faster, if you work in base 4 instead and replace integer division by bit shifts. Iterating and in particular iterating combination is excruciatingly slow in python even when using itertools. So do yourself a favor, and write c++ code for these kind of things so that you don't have to have memory allocations inside loops. |