Open iheteroclite opened 1 year ago
As mentioned in commit message 0660d6c, after some research this appears to be a subset of a hypergeometric distribution , which is not well modeled in the case of matching pairs.
Issue found: probabilities not updating correctly.
Player blackjack win count self.blackjack_wins
is being updated in the check_twenty_one
function, but the player.probabilities
list dictionary element's blackjack
counter is only being updated in the score_hand
function - meaning that if the dealer has blackjack, then the player's blackjack is not correctly updated (as player.hand.state == 'push'
Now fixed, the chance of B blackjacks is based on the mean of all the probabilities for a single blackjack. This is a good model but does have one drawback - it doesn't have a 0 probability of B blackjacks in the use case where a user got any blackjack on a round with 0 chance of getting a blackjack. The chance of getting B blackjacks if they got a blackjack on that round should be 0.
Tested current formulae with Mathematica, and am getting very reasonable results. The statistics seem to update well, but I do need to display the chance of a user having got a single win this round... Which I will re-open in another issue.
Keeping this open until I have uploaded all documentation R.E. formulaic tests.
I have assumed a binomial distribution and created an algorithm which estimates the probability given a fixed sampling length (which blackjack has, one sample per round), however there is a variable chance of getting a single blackjack each round. That probability is dependent on the number of cards in the deck, the number of ten-values in the deck, the number of cards in the deck, and the number of previous blackjacks won by a particular player.
The formula I calculated models the probability of getting B blackjacks over N rounds as a fixed average of this varying probability. Using a fixed average probability means that the chance can be treated similarly to an ideal coin toss, it has a 50/50 change of falling on a particular side, and a fixed sampling rate, so the only variation is the number of heads/tails. This allowed for a relatively easy computation of the mean and sd of a binomial.
Unfortunately, this model will not accurately calculate the probability of getting at least a particular number of blackjacks, given the specific deck conditions (which are variable).
As this seems like a problem that does not have an accepted solution online either, I will try to tackle it. I need to find the probability of a particular result for a binomial distribution over N rounds, where the probability of blackjack on any one round is unique to that round.