May 14th, 2009, 6:38 pm
QuoteOriginally posted by: quantystQuoteOriginally posted by: Junior08Got this at a junior analyst position at a fund.You have a bag of jelly beans in both of your pockets. Each bag contains 4 jelly beans. You eat one jelly bean at a time, each time reaching into a random bag... eventually, you reach into a bag and it's empty. What is the expected number of jelly beans remaining in the other bag. Part two... what is each bag contains 100 beans?Solution:Let's generalize the problem.Assume that in the beginning the left pocket has m beans, and the right pocket has n beans. And let E(m,n) denote the expected number of beans in the non-empty pocket when one of the pockets becomes empty.Clearly E(m,n)=E(n,m), E(m,0)=m, and E(0,n)=n.On the first pick of a bean, either the left pocket is decreased by one bean with probability 1/2 or the right pocket is decreased by one bean with probability 1/2. ThusE(m,n)=(1/2)E(m-1,n)+(1/2)E(m,n-1).All we need to do now is to solve the above recursion.Or, we can iterate it until we get the required result.QuoteOriginally posted by: everforgetAgain, the method is good but you misunderstood the puzzle. E( 0, n ) is not n.O.K. I need to get the initial values correct.Suppose we start with 0 beans in the left pocket and n beans in the right pocket. Upon first choice of a pocket, either the hand goes to the left pocket with a probability of 1/2, in which case the process stops and there will be n beans in the other pocket, or the hand goes to the right pocket with probability of 1/2, in which case the process will continue with 0 beans in the left pocket and (n-1) beans in the right pocket. So, we have:E(0,n)=(n/2)+(E(0,n-1)/2), with E(0,0)=0.Solving the above, we get:E(0,n)=(n-1)+(1/(2^n)).Done ... (except for a closed form of the main recursion).
Last edited by
quantyst on May 14th, 2009, 10:00 pm, edited 1 time in total.