# Thread: Magic Beans Selection Problem

1. ## Magic Beans Selection Problem

You have 2 bags of beans containing 10 beans each. In each bag, there 3 magic beans. How do you maximize the number of magic beans selected if you are allowed to pick 10 beans out of the 20 altogether? You can mix them if you want but the 10 has to be selected simultaneously not one at the time...
i.e. If you do not mix the bags and just pick any one bag, you know you will get a minimum of 3 magic beans out of 10 but can you achieve more?

This portfolio managment problem is related to picking the best 3 performing stocks from 2 different sectors. The problem is you won't know which 6 will perform best until end of the year but you are allowed to pick 10 from 20 and you want the portfolio to include as close to all 6 best as possible. Is there a way to optimize the selection process?
i.e. You can't draw one at a time to see if it is normal or not and then pick another from the other bag because you will only know whether it is a good stock at the end of the year.

2. ## Re: Magic Beans Selection Problem

Originally Posted by scalpmaster
You have 2 bags of beans containing 10 beans each. In each bag, there 3 magic beans. How do you maximize the number of magic beans selected if you are allowed to pick 10 beans out of the 20 altogether? You can mix them if you want but the 10 has to be selected simultaneously not one at the time...
i.e. If you do not mix the bags and just pick any one bag, you know you will get a minimum of 3 magic beans out of 10 but can you achieve more?

This portfolio managment problem is related to picking the best 3 performing stocks from 2 different sectors. The problem is you won't know which 6 will perform best until end of the year but you are allowed to pick 10 from 20 and you want the portfolio to include as close to all 6 best as possible. Is there a way to optimize the selection process?
i.e. You can't draw one at a time to see if it is normal or not and then pick another from the other bag because you will only know whether it is a good stock at the end of the year.
The only thing that you can control is the number of n beans selected from bag 1 (the number from bag 2 is then 10-n).

So if you take n from bag 1 and 10-n from bag 2 what is the expected number of magic beans in your selection?

The number of magic beans i, obtained when n beans are slected from a bag containing a total of N beans k of which are magic has a hypergeometric distribution h(i;N,k,n)

CB

3. ## Re: Magic Beans Selection Problem

Originally Posted by CaptainBlack
The only thing that you can control is the number of n beans selected from bag 1 (the number from bag 2 is then 10-n).
So if you take n from bag 1 and 10-n from bag 2 what is the expected number of magic beans in your selection?
CB
Does the expected no. increase or decrease with n?

4. ## Re: Magic Beans Selection Problem

Originally Posted by scalpmaster
Does the expected no. increase or decrease with n?
If it increased or decreased with n then you would be best off choosing all the beans from one bag. If you can do any better on average than 3 magic beans the optimum(s) will occur with a mixed choice.

If you know the mean of the hypergeometric distribution you can write the expected number of magic beans as the sum of the mean number of magic beans if you chose n from a bag and the mean number of magic beans if you choose (10-n) from a bag. (You will find that the answer is what you might have suspected from the start, the mean number is independent of how you split the choice between bags)

CB

5. ## Re: Magic Beans Selection Problem

Thanks for the explanation.