Re: bisection method: Simulating a retirement fund

2010-09-03 Thread Carl Banks
On Sep 2, 1:37 pm, Baba wrote: > level: beginner In this economy, simulating the value of retirement funds with bisection is easy. Look: def retirement_fund_value(n_years,initial_value): for i in xrange(n_years): value /= 2 # <- bisect value of fund return value Carl Banks --

Re: bisection method: Simulating a retirement fund

2010-09-03 Thread MRAB
On 03/09/2010 09:06, Baba wrote: On Sep 2, 11:10 pm, MRAB wrote: Why are you saving 'fund' in SavingsRecord if you're returning just the last and discarding others? Basically you're returning the final value of fund. Hi MRAB ok i agree that this is not be ideal. I should shorten this to ONL

Re: bisection method: Simulating a retirement fund

2010-09-03 Thread Baba
On Sep 2, 11:10 pm, MRAB wrote: > > Why are you saving 'fund' in SavingsRecord if you're returning just the > last and discarding others? Basically you're returning the final value > of fund. Hi MRAB ok i agree that this is not be ideal. I should shorten this to ONLY return SavingsRecord[-1] >

Re: bisection method: Simulating a retirement fund

2010-09-02 Thread MRAB
On 02/09/2010 21:37, Baba wrote: level: beginner exercise source: http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-00-introduction-to-computer-science-and-programming-fall-2008/assignments/pset4.pdf Problem 4 Can my code be optimised? I think my approach is correct but

bisection method: Simulating a retirement fund

2010-09-02 Thread Baba
level: beginner exercise source: http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-00-introduction-to-computer-science-and-programming-fall-2008/assignments/pset4.pdf Problem 4 Can my code be optimised? I think my approach is correct but i am hesitant about the initial max