1
$\begingroup$

I have an array that looks something like this:

$a = [0.01, 0.01, 0.50, 0.03, 0.20, 0.10, 0.15]$

This is just an example, but it shows that $sum(a) = 1$. Each number in the array represents the probability of choosing that item.

How do I calculate the probability of choosing the same item twice (or more generally, $n$ times in a row)? Choosing the first item ($0.01$) and the second item ($0.01$) counts as choosing two different items, i.e. only the index in the array matters.

(Sorry for any obvious mistakes, this is my first question here.)

1 Answers 1

3

Say your vector of probabilities is $a_1,\ldots,a_n$. Then the probability of picking the $i$th item on the first pick is $a_i$, and the probability of picking it on the second pick is also $a_i$, so the probability of picking the $i$th item twice is $a_i^2$.

Then picking the same item twice in two picks is the sum of this for each possible item:

$\sum_{i=1}^n{a_i^2}$

and the chance of picking the same item $k$ times in $k$ picks is:

$\sum_{i=1}^n{a_i^k}$

(Unless I completely misunderstood your question, you did not make any obvious mistakes.)