Created
March 23, 2016 01:08
-
-
Save rbtcollins/babb983b8939b051fe5d 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
import csv | |
f = open('income-distribution.csv', 'rt') | |
l = list(csv.reader(f)) | |
pre = l[5:157] | |
# top edge, lower edge, % | |
brackets = [(14000, 0, 0.105), (48000, 14001, 0.175), (70000, 48001, 0.30), (200000, 70001, 0.33)] | |
total = 0 | |
for (_, people, total_income, _) in pre: | |
people = float(people) | |
total_income = float(total_income) * 1000000 | |
avg = total_income/people | |
newincome = avg + 11000 | |
for idx, (threshold, lower, pct) in enumerate(brackets): | |
if threshold > newincome: | |
break | |
# tax from the new bracket | |
base = max(lower, avg) | |
newtax = (newincome-base) * people * pct | |
# 10K, 48 > 21. | |
if lower > avg: | |
# crosses a bracket | |
newtax += (lower-avg) * people * brackets[idx-1][2] | |
print("avg: %s, newtax: %s" % (avg, newtax/1000000)) | |
total += newtax | |
print("Total: %s" % (total/1000000)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment