I have a weighted prob question. How do you find the combinations of weighted probabilities whose sum is equal to a fixed number? For example: suppose you are given a basket of fruits that have different costs. If you have a specific budget, what different ways can you spend that money.. To illustrate:

You want apples oranges and bananas and you have $3.50 to spend. Apples cost $0.50 each Oranges cost $0.20 each Bananas cost $0.89 each

Let there exist a set {a_1, a_2, a_3} such that a_1(.5) + a_2(.2) + a_3(.89) = 3.5

List the possible combinations of {a_1, a_2, a_3}

  • 1
    $\begingroup$ are you talking about integer solutions for $a_i$? What does this to do with probability? $\endgroup$ – karakfa Oct 18 '19 at 18:29

It looks like you are looking for integer solutions such that you spend less than or equal to your budget.

I would look at this problem from starting with one "fruit" and increasing the number of fruits. So if you just had apples, you could buy 7 (7,0,0). For the other variables, since their prices don't evenly divide 3.5, I would look at what is the largest number you can purchase with your budget. We can constrain your problem to look only at values in between (7,0,0), (0,17.5,0) and (0,0,3.94). Oranges are the cheapest product, so lets start with the most oranges and adjust down. I will use the notation (a_1,a_2,a_3|total cost). If you are interested in only triplets that combine to the exact total budget, the problem is much easier since in your example .89 has a hundredths digit and you would have to buy a multiple of ten in order to get to your exact budget.

For exact budget we have (7,0,0), (5,5,0), (3,10,0), (1,15,0) as the only solutions, since .5 divides 3.5 and lcm(.2,.5)=1 means that we must change how much product we buy in 1 dollar increments (1 dollar less of apples and 1 dollar more of oranges.

To solve for any combination that costs less than your budget, start with (0,17,0|3.4) and decrease the number of oranges bought. Then look for all combinations that satisfy your budget (0,17,0|3.4),(0,16,0|3.2),(1,15,0|3.5),(1,14,0|3.3), (1,13,0|3.1), (0,13,1|3.49) and so on.

| cite | improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.