A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 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/ .

  • This Question is Closed
  1. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    I did a little more but I'm still lost on guessing part. http://dpaste.com/hold/529031/

  2. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    on 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 half-way 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 (half-way 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.

  3. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Lines 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.

  4. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    egg = 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

  5. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    think simple.

  6. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Is that supposed to be a functional code or just something to give me an idea of how to do it?

  7. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    I got it thank you

  8. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    hmm ... i thought the intent of pset4 problem 4 was to do a write a solution using a binary search - not just get an answer.

  9. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Wait, what do you mean?

  10. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    It 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.

  11. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Sorry what is binary search I don't remember

  12. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    http://en.wikipedia.org/wiki/Binary_search#Implementations its sorta covered (the bisectional sqrt function)... but binary search is not explicitly covered until lecture 9.

  13. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    I think that is what I did? http://dpaste.com/hold/529521/

  14. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Here's what I got: http://pastebin.com/eauphLLR

  15. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    We did the same thing pretty much.

  16. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    One 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.

  17. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    sorry - http://dpaste.com/529892/

  18. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Ok 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.

  19. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

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
  • 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.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.