2
$\begingroup$

I'm not even sure I'm phrasing the question properly, please let me know if there is any standard terms around this type of problem.

I'm trying to find an average number of attempts it would take to find a randomly placed pixel within a fixed size element. If a wrong pixel is chosen, it is removed from the choices.

Scenario:

There is a 100 x 100 pixel square. 1 pixel is the winning pixel, all others are losers. Remove each losing pixel as they are chosen.

A 100x100 square has a total of 10,000 pixels. Is the probability simply determined by multiplying 1/10000 * 1/9999 * 1/9998 * 1/9997 ....

How can I arrive at a number that gives me an idea of an average number of clicks it would take to find the winning pixel? I.e. can I run 1000 of these scenarios and get a fairly accurate estimate?

$\endgroup$

2 Answers 2

1
$\begingroup$

You're looking to calculate expected value of a variable $X$, which we define as number of clicks until success.

$$E[X] = \sum_{i=1}^{10,000} i \cdot Pr(X = i)$$

Note that for each possible $i \in \{1,2,...,10000\}$, $Pr(X=i) = \frac{1}{10,000}$. Thus,

$$E[X] = \sum_{i=1}^{10,000} \frac{i}{10,000} = 5000.5$$

Running the scenario 1000 times could get you close-ish to this answer. In R:

set.seed(1)
mean(replicate(1000, which(sample(1:10000, replace = F) == 1)))
$\endgroup$
1
  • $\begingroup$ I selected this as the best answer since it covered all concerns (ie) $\endgroup$
    – Flignats
    Commented Jan 22, 2019 at 21:40
0
$\begingroup$

Well, simply write the expected value formula, i.e. $\sum{xp(x)}$:

$$E[X]=1\times\frac{1}{10000}+2\times\frac{9999}{10000}\times\frac{1}{9999}+...=\frac{10000\times10001}{2}\times\frac{1}{10000}=\frac{10001}{2}$$

where $X$ is the number of throws needed.

$\endgroup$
1
  • $\begingroup$ Thanks for the quick response - this was also the correct solution. $\endgroup$
    – Flignats
    Commented Jan 22, 2019 at 21:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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