Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 7 Online
OpenStudy (anonymous):

Looking at ps4, simulating a retirement fund. I made the following test data for the final part. salary = 10000 save = 10 preRetireGrowthRates = [3, 4, 5, 0, 3] postRetireGrowthRates = [80, 80] # proves that max estimate of savings at retirement + epsilon is too small epsilon = .01 expenses = findMaxExpenses(salary, save, preRetireGrowthRates, postRetireGrowthRates, epsilon) print expenses # Output should have a value close to: # 6093.81174046 Do you think we were given the bogus hint

OpenStudy (anonymous):

It looks like your question got cut off, but I think I see what you're saying. With huge growths of 80% and 80% our savings will grow so fast that even spending all our (initial) money each year won't deplete our savings. (An even easier to understand example is one year of 200% growth.) So, we have to pick a starting expense of more than our nest egg, which is what they said should be the high range of our initial guess.|dw:1318382066726:dw|I think they mention that problem of binary search in the lectures, but, yes, they failed to account for it here. It's because we add the interest for the year before subtracting our expenses. We really have to make a first initial guess that takes the first year's growth into account, too. I changed my code to do this: high = nestEgg * (1 + postRetireGrowthRates[0]) That's my first guess for high (low starts at 0). That worked. Good catch. Excellent job testing.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!