Created
October 19, 2020 15:46
-
-
Save new5558/a287270f64abfb8bdb3dd5923bf4d777 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
investment_money = float(input()) #k | |
remaining_life = int(input()) #n | |
withdraw_money = 0.09*investment_money #w | |
my_mean = float(input())/100 | |
my_std = float(input())/100 | |
import numpy as np | |
loss_time = 0 | |
CALCULATIONS = 10000 | |
for i in range(CALCULATIONS): | |
x = np.random.normal(loc=my_mean, scale=my_std, size=remaining_life) | |
current_investment_money = investment_money | |
for i in range(remaining_life): | |
current_investment_money = current_investment_money - withdraw_money | |
if current_investment_money > 0: | |
current_investment_money *= (1+x[i])/(1+2.73/100) | |
else: | |
loss_time = loss_time + 1 | |
break | |
print(loss_time*100/CALCULATIONS) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment