Created
January 13, 2020 13:38
-
-
Save jimtje/57a140964602429568ca04bbaf1713a0 to your computer and use it in GitHub Desktop.
This file contains 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
def calc_prop_length(run_length, total_length, success_probability): | |
P = [None for i in range(0, total_length + 1)] | |
fail_probability = 1 - success_probability | |
for i in range(0, run_length): | |
P[i] = 0 | |
P[run_length] = success_probability ** run_length | |
for i in range(run_length, total_length): | |
P[i + 1] = P[i] + (1 - P[i - run_length]) * fail_probability * (success_probability ** run_length) | |
return P[total_length] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment