Created
August 16, 2018 21:44
-
-
Save tommycarstensen/acf871456137ffe4fb5500ef07025cc7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 random | |
import matplotlib.pyplot as plt | |
var = 0.10 | |
colors = ('#a6cee3', '#1f78b4', '#b2df8a', '#33a02c') | |
##for iColor, (tax1, tax2) in enumerate(((0.42, 0), (0.27, 0), (0, 0.42), (0, 0.27))): | |
for tax1, tax2 in ((0.42, 0),): | |
## for rate in (0.08,): | |
for iColor, rate in enumerate((0.04, 0.08, 0.12, 0.16)): | |
## for iColor, years in enumerate((10, 20, 30, 40)): | |
for years in (30,): | |
x = [] | |
for i in range(100000): | |
v0 = v = 100000 | |
for year in range(years): | |
v *= 1 + ((rate - var + 2 * var * random.random()) * (1 - tax1)) | |
## print(i, year, v) | |
print(v, (v - v0), (v - v0) * (1 - tax2)) | |
v -= (v - v0) * tax2 | |
print(v) | |
## print(tax1, tax2, rate, i, v) | |
x.append(v) | |
plt.hist( | |
x, bins=100, alpha=.5, | |
color = colors[iColor % 4], | |
label='Tax {}%/{}%, Compounding {}%, Years {}'.format( | |
100*tax1, 100*tax2, 100*rate, years), | |
) | |
plt.legend() | |
##plt.savefig('compounding_tax.png') | |
plt.savefig('compounding_rate.png') | |
##plt.savefig('compounding_years.png') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment