Skip to content

Instantly share code, notes, and snippets.

@DUznanski
Created August 22, 2016 04:26
Show Gist options
  • Save DUznanski/d1032efb260509b7907f939b4be2fd77 to your computer and use it in GitHub Desktop.
Save DUznanski/d1032efb260509b7907f939b4be2fd77 to your computer and use it in GitHub Desktop.
#!/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