Skip to content

Instantly share code, notes, and snippets.

@iitalics
Created August 12, 2025 17:28
Show Gist options
  • Select an option

  • Save iitalics/2a608b7998ff08489f0b856e2e1960ed to your computer and use it in GitHub Desktop.

Select an option

Save iitalics/2a608b7998ff08489f0b856e2e1960ed to your computer and use it in GitHub Desktop.
# expected rate to get n drops
def true_exp(n):
if n <= 0:
return 0
p_2 = 1/100 # 2 drops
p_1 = 18/100 # 1 drop
p_0 = 81/100 # 0 drops
# E_n = 1 + p_2 E_(n-2) + p_1 E_(n-1) + p_0 E_n
# (1 - p_0) E_n = 1 + p_2 E_(n-2) + p_1 E_(n-1)
# E_n = (1 + p_2 E_(n-2) + p_1 E_(n-1)) / (1 - p_0)
e_2 = true_exp(n - 2)
e_1 = true_exp(n - 1)
return (1 + p_2 * e_2 + p_1 * e_1) / (1 - p_0)
print(true_exp(10))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment