# Probability of an indexing random variable

Assume we have $$n$$ cards, indexed successively by the integers $$1$$ to $$n$$. Now each card is either marked or not. Suppose that card $$i$$ is marked with probability $$p_i$$, independently of the others.

Let the r.v. $$X = 0, 1,...$$ be the highest index among the marked cards (with $$X = 0$$ if all cards are unmarked).

What is $$P(X=k)$$ for $$0 \leq k \leq n$$ , $$P(X \geq k)$$ and $$P(X \geq k| k \geq 1)$$ for $$1 \leq k \leq n$$ ?

Does $$X$$ follow the distribution of the maximum?

For $$P(X=k)$$ when I compute $$P(X=0)$$ get $$P(X=0) = \Pi_i (1-p_i)$$ then $$P(X=1) = \sum_{i=1}^n p_i(\Pi_{j \neq i} (1-p_j))$$, but I think I am doing this wrong?

You can think iteratively from the card numbered $$n$$. This one is marked with probability $$p_n$$. So we have the probability $$P(X=n)=p_n.$$ Now think about the case $$X=n-1$$ in this case, the $$n^\text{th}$$ card is unmarked and the $$(n-1)^\text{th}$$ is marked. This has probability $$P(X=n-1)=(1-p_n)p_{n-1}.$$ You probably can take it from here.