A community for students.
Here's the question you clicked on:
 0 viewing
anonymous
 5 years ago
Hey can anyone help me on the guessing method used in pset4 problem 4. This is what I have so far
http://dpaste.com/hold/528870/
.
anonymous
 5 years ago
Hey can anyone help me on the guessing method used in pset4 problem 4. This is what I have so far http://dpaste.com/hold/528870/ .

This Question is Closed

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0I did a little more but I'm still lost on guessing part. http://dpaste.com/hold/529031/

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0on line 18 of your second dpaste you are multiplying the growth rate by .001  is that what you want? at line 24: expenses = savings At lines 27 and 29 you modify expenses add a print statement after line 29 but still inside the while loop: print "expenses:", expenses what is happening to expenses? is it doing what you want it to do? For the binary search at the end (lines 25+) you want to start off with a range of expenses  maybe min_expense = 1 and max_expense = savings Those are the two extremes  your answer is between them. You want to start off halfway between the extremes  maybe call it mid_expense. Test it If mid_expense is too large then you know that the answer is somewhere between mid_expense and min_expense  those are your new extremes  set max_expense = mid_expense then calculate a new mid (halfway between the new min and max). If mid_expense is too small then you know the answer is between mid_expense and max_expense  those are your new extremes. Set min_expense = mid_expense and calculate a new mid (between the new min and max) Now it is time to loop and try it again with the new min/mid/max. put a print statement at the bottom of the loop to print min/mid/max so you can watch how they are changing and see if they are doing what you think they should do.

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0Lines 25+ were guesses to try and figure it out because people weren't replying so I was trying to do it by myself but couldn't figure it out so I just posted what I had.

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0egg = nestEggVariable() savings = egg[1] dif = epsilon * 2.0 years = len(postRetireGrowthRates) guess = savings/years while dif > epsilon account = postRetirment() dif = account[1] guess += dif/years return expenses

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0Is that supposed to be a functional code or just something to give me an idea of how to do it?

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0hmm ... i thought the intent of pset4 problem 4 was to do a write a solution using a binary search  not just get an answer.

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0Wait, what do you mean?

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0It does say that but i am unsure how to make a binary search work in this question. Also does not explain binary search until lecture 9 which is 2 lectures after ps4 is due.

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0Sorry what is binary search I don't remember

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0http://en.wikipedia.org/wiki/Binary_search#Implementations its sorta covered (the bisectional sqrt function)... but binary search is not explicitly covered until lecture 9.

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0I think that is what I did? http://dpaste.com/hold/529521/

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0Here's what I got: http://pastebin.com/eauphLLR

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0We did the same thing pretty much.

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0One of the readings for lectures 7&8 was the wikipedia entry for binary search. Binary search method/algorithm is introduced (with code) at about 37min 30sec of lecture 8 (but you should probably start watching earlier in the lecture). but pset4 was due for lecture 8  sorry  maybe I went back and rewrote it  then again I do a lot of side reading in between lectures and take my time on the problems. here's wha I got, fwiw, http://dpaste.com/529890/. left in the print statements.

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0sorry  http://dpaste.com/529892/

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0Ok sorry to keep asking this but what actually is binary search is it the part where you do (min+max)/2 and see if it is to big or too small and repeat.
Ask your own question
Sign UpFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.