Created
August 22, 2016 04:26
-
-
Save DUznanski/d1032efb260509b7907f939b4be2fd77 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
#!/usr/bin/env/python3 | |
import random | |
gaps = [] | |
events = 0 | |
current_gap = 0 | |
for trial in range(1000000): | |
if random.random() < (1/500): | |
gaps.append(current_gap) | |
current_gap = 0 | |
events += 1 | |
else: | |
current_gap += 1 | |
print(events, '500-year floods') | |
print(sum(gaps)/len(gaps), 'mean years between 500-year floods') | |
print(sorted(gaps)[len(gaps)//2], 'median years between 500-year floods') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment