Probability problem; adding elements to a list then picking from that list

78 Views Asked by At

It seems like a very simple problem but I couldn't figure out the solution myself (not homework)

Simplified it's the following: 10% chance to add 1 to a list 20% chance to add 2 to a list 30% chance to add 3 to a list 40% chance to add 4 to a list

and from that list I pick 1 number.

How much chance is there to get a specific number? Running a simulation in matlab gave me: 29.3% to get 4; 20.9% to get 3; 13.5% to get 2; 6.2% to get 1; 30.1% to get 0 numbers in a list so no number could be picked.

2

There are 2 best solutions below

2
On

I don't think there is an easy way. The chance you get $4$ is $0.4$ (that you added $4$ at all) times $\Big[(1-0.1)(1-0.2)(1-0.3)$ (that it is the only number on the list) plus $\frac 12\big(0.1(1-0.2)(1-0.3)+(1-0.1)0.2(1-0.3)+(1-0.1)(1-0.2)0.3\big)$ (because one other number was added) plus $\ldots\Big]$ and the dots have the cases where two or three other numbers were added.

0
On

Let $p(n)\ (n\in\{1,2,3,4\})$ be the probability that number $n$ is added to the list (e.g., your $0.1, 0.2, 0.3, 0.4$). Then a formula for the probability that the outcome is the specific number $x$ is $$1(Abcd)+{1\over 2}(ABcd+AbCd+AbcD)+{1\over 3}(ABCd+ABcD+AbCD)+{1\over 4}(ABCD) $$ where $$\begin{align}A&=p(x)\\ B&=p(1+(x\bmod 4))\\ C&=p(1+((x+1)\bmod 4))\\ D&=p(1+((x+2)\bmod 4))\\ \end{align}$$ and $a=1-A,\ b=1-B,\ c=1-C,\ d=1-D.$

Note that $B,C,D$ are simply the add-to-the-list probabilities for the three other numbers besides $x$, and they may be taken in any order. (The above formula just uses $\bmod 4$ to express the choice of taking them in cyclic order.)

In Sage:

def p(x): return [1/10, 2/10, 3/10, 4/10][x-1]
def Pout(x):
    A = p(x)
    B = p(1 + (x%4))
    C = p(1 + ((x+1)%4))
    D = p(1 + ((x+2)%4))
    a = 1 - A
    b = 1 - B
    c = 1 - C
    d = 1 - D
    return (A*b*c*d)+(A*B*c*d+A*b*C*d+A*b*c*D)/2+(A*B*C*d+A*B*c*D+A*b*C*D)/3+(A*B*C*D)/4

print [Pout(x) for x in [1..4]], 1-sum([Pout(x) for x in [1..4]])
print [Pout(x).n() for x in [1..4]], 1-sum([Pout(x).n() for x in [1..4]])

[473/7500, 1981/15000, 521/2500, 4411/15000] 189/625
[0.0630666666666667, 0.132066666666667, 0.208400000000000, 0.294066666666667] 0.302400000000000