Skip to content

Instantly share code, notes, and snippets.

@luispedro
Created October 13, 2012 08:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luispedro/3883828 to your computer and use it in GitHub Desktop.
Save luispedro/3883828 to your computer and use it in GitHub Desktop.
import numpy as np
from matplotlib import pyplot as plt
def irs_paid(val):
paid = 0
def sub0(y, x):
if (val <= y): return 0;
if (val < x): return val - y;
return x - y;
return sub0(0,7000)*0.145 + sub0(7000,20000)*0.285 + sub0(20000,40000)*0.37 + sub0(40000,80000)*0.45 + (val - 80000 if (val > 80000) else 0) * 0.48;
def total_contrib(val):
raw = val * 1.2375;
after_ss = 0.89 * val;
irs = irs_paid(after_ss);
irs_rate = irs / after_ss;
after_irs = after_ss - irs;
contribution = raw - after_irs;
contribution_rate = contribution/raw;
return contribution_rate
salary = np.arange(1,5000*12,5)
contrib = np.array(map(total_contrib, salary))
plt.ylim(0,80)
plt.plot(salary/12., contrib*100, 'b', lw=4, label='Tax on labour')
plt.plot(salary/12., 15+contrib*100, 'g', lw=4, label='Add VAT (at 15%)')
plt.xlabel('Salary (per month, 12 salaries)')
plt.ylabel('Total tax rate (%)')
plt.legend(loc='best')
plt.savefig('taxrates.png')
import numpy as np
from matplotlib import pyplot as plt
def irs_paid(val):
paid = 0
def sub0(y, x):
if (val <= y): return 0;
if (val < x): return val - y;
return x - y;
return sub0(0,7000)*0.145 + sub0(7000,20000)*0.285 + sub0(20000,40000)*0.37 + sub0(40000,80000)*0.45 + (val - 80000 if (val > 80000) else 0) * 0.48;
def total_contrib(val):
raw = val * 1.2375;
after_ss = 0.89 * val;
irs = irs_paid(after_ss);
irs_rate = irs / after_ss;
after_irs = after_ss - irs;
contribution = raw - after_irs;
contribution_rate = contribution/raw;
return contribution_rate
salary = np.arange(1,5000*12,5)
contrib = np.array(map(total_contrib, salary))
plt.ylim(0,80)
plt.plot(salary/12., contrib*100, 'b', lw=4, label='Tax on labour')
plt.plot(salary/12., 15+contrib*100, 'g', lw=4, label='Add VAT (at 15%)')
plt.xlabel('Salary (per month, 12 salaries)')
plt.ylabel('Total tax rate (%)')
plt.legend(loc='best')
plt.savefig('taxrates.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment