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

At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get our expert's

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions.

A community for students.

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

MIT 6.00 Intro Computer Science (OCW)
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions

I did a little more but I'm still lost on guessing part. http://dpaste.com/hold/529031/
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.
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.

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

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
think simple.
Is that supposed to be a functional code or just something to give me an idea of how to do it?
I got it thank you
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.
Wait, what do you mean?
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.
Sorry what is binary search I don't remember
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.
I think that is what I did? http://dpaste.com/hold/529521/
Here's what I got: http://pastebin.com/eauphLLR
We did the same thing pretty much.
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.
sorry - http://dpaste.com/529892/
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.

Not the answer you are looking for?

Search for more explanations.

Ask your own question