Created
August 12, 2025 17:29
-
-
Save iitalics/509b1afc65fcd425cf8f791556a0d484 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # expected rate to get n drops | |
| def true_exp(n): | |
| if n <= 0: | |
| return 0 | |
| p2 = 1/100 # 2 drops | |
| p1 = 18/100 # 1 drop | |
| p0 = 81/100 # 0 drops | |
| # E(n) = 1 + p2 E(n-2) + p1 E(n-1) + p0 E(n) | |
| # (1 - p0) E(n) = 1 + p2 E(n-2) + p1 E(n-1) | |
| # E(n) = (1 + p2 E(n-2) + p1 E(n-1)) / (1 - p0) | |
| e2 = true_exp(n - 2) | |
| e1 = true_exp(n - 1) | |
| return (1 + p2 * e2 + p1 * e1) / (1 - p0) | |
| print(true_exp(10)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment