norvig / pytudes

Python programs, usually short, of considerable difficulty, to perfect particular skills.
MIT License
23.11k stars 2.43k forks source link

Wordle: Adjust expected_wins for bin size #121

Open jobevers opened 2 years ago

jobevers commented 2 years ago

Let M = 2315 (total number of possible answers) and n = the size of bin for pattern n.

In the original version

P(Guess in 2) = 1/M * Sum(Prob(Guess in 2 | Pattern))
              = 1/M * Sum(1 / n) 

But, by Total Probability, I believe the formula should be:

P(Guess in 2) = Sum(Prob(Guess in 2 | Pattern) * P(Pattern))
              = Sum(1 / n * n / M)
              = 1 / M * Sum(1)

The result is counter-intuitive to me, but the probability of a guess in 2 only depends on the number of (non-empty) bins/partitions that are created from a guess.

Credit to @fitzme for help verifying the math.