Given two basketball players.

John made 38/50 free throws. Mike made 80/100 free throws.

What is probability that Mike is better at free throws than John?

  • 1
    $\begingroup$ The answer depends upon what prior knowledge you have. You might get a different answer if you know John is the captain of the basketball team. $\endgroup$ Feb 10 '11 at 20:37
  • $\begingroup$ assume zero prior knowledge $\endgroup$ Feb 10 '11 at 22:07
  • 1
    $\begingroup$ Assuming a uniform prior, the answer is 848437653385740282130263/1167635946155025951609137 = about 72.66%. $\endgroup$
    – whuber
    Feb 10 '11 at 22:35
  • $\begingroup$ Michael McGowan's point is that you must make some such assumption in order to obtain an answer. It's like asking whether a cannonball or a feather will hit the ground first without specifying how high each one was when dropped: if you are ignorant of that essential information, you simply cannot provide a justified answer, even though the problem makes sense and physical theory exists to solve it for any given pair of heights. $\endgroup$
    – whuber
    Feb 10 '11 at 22:38

Okay. I think I figured out the general answer:

Given a sample of n/N made, the probability that the population success rate is greater than x is defined by the posterior probability distribution:

$\frac{\int_{x}^1 r^n(1-r)^{N-n}\ dr}{\int_{0}^1 r^n(1-r)^{N-n}\ dr}$

So for my example the chance that Mike's free throw percentage is greater than x is:

$\frac{\int_{x}^1 r^{80}(1-r)^{20}\ dr}{\int_{0}^1 r^{80}(1-r)^{20}\ dr}$

We then need to integrate that over the probability distribution for John's free throw percentages:

$\frac{\int_{0}^1 \int_{x}^1 x^{38}(1-x)^{12} r^{80}(1-r)^{20}\ dr\ dx}{\int_{0}^1 x^{38}(1-x)^{12}\ dx \int_{0}^1 r^{80}(1-r)^{20}\ dr}$

Which as whuber said is ~ 72.66%

For the WolframAlpha solution:

Integrate[y^38 (1 - y)^12 x^80 (1 - x)^20, {x, 0, 1}, {y, 0, x}]/(Integrate[y^38 (1 - y)^12, {y, 0, 1}] Integrate[x^80 (1 - x)^20, {x, 0, 1}])

  • $\begingroup$ This is correct! The denominator of course is the product of two Beta functions. The numerator is equivalent to the generalized hypergeometric function I referred to. $\endgroup$
    – whuber
    Feb 11 '11 at 4:16
  • $\begingroup$ @whuber Thank you for getting me started. I'm still new to stats so I had to scour wikipedia and my long forgotten calculus for help. $\endgroup$ Feb 11 '11 at 4:20

I think what you want to do is compare the predictive distributions of both players. The predictive distribution describes the probability that Mike/John will make his next shot given the data (integrating out the parameters).

Here is some Matlab code you can play with:

rng = linspace(0, 1, 100);

% data
j = [38 50];
m = [80 100];

% priors (I assume uniform, but you can integrate external knowledge here)
a0 = 1;
b0 = 1;

% posterior distribution for each player
post_j = [a0 + j(1), b0 + j(2) - j(1)];
post_m = [a0 + m(1), b0 + m(2) - m(1)];

% visualize
postj = betapdf(rng, a0 + j(1), b0 + j(2) - j(1));
postm = betapdf(rng, a0 + m(1), b0 + m(2) - m(1));
figure(1); plot(rng, postj, 'r',...
                rng, postm, 'k');
title('Posterior Distributions');
legend('Jon', 'Mike');


SAMPLES = 5000;

predj = zeros(SAMPLES, 1);
predm = zeros(SAMPLES, 1);
for i = 1:SAMPLES
    pj = betarnd(post_j(1), post_j(2));
    lj = binornd(1, pj);
    predj(i) = lj;

    pm = betarnd(post_m(1), post_m(2));
    lm = binornd(1, pm);
    predm(i) = lm;

% Comparison of (sampled) predictive distributions:
fprintf('P(d_john | Dj) > P(d_mike | Dm) = %.3f\n', sum(predj > predm) / SAMPLES);
fprintf('P(d_john | Dj) < P(d_mike | Dm) = %.3f\n', sum(predj < predm) / SAMPLES);
fprintf('P(d_john | Dj) = P(d_mike | Dm) = %.3f\n', sum(predj == predm) / SAMPLES);

pred_j = sum(predj) / SAMPLES;
pred_m = sum(predm) / SAMPLES;

fprintf('Probability that John will make his next shot: %.4f\n', pred_j);
fprintf('Probability that Mike will make his next shot: %.4f\n', pred_m);
  • $\begingroup$ Aren't the probabilities for John and Mike to make their next shot simply respectively 0.76 and 0.8? Either way, that's not what I'm trying to determine. What I'd like to calculate is the probability (given the limited observations) that Mike has a higher free throw percentage than John. $\endgroup$ Feb 10 '11 at 22:21
  • $\begingroup$ +1. The posterior probability that Mike, with distribution $B(\alpha,\beta)$, is better than John, with distribution $B(\gamma,\delta)$, is proportional to a generalized hypergeometric distribution. This can be computed either as a polynomial or as a rapidly converging power series, giving far greater computational accuracy than any simulation. $\endgroup$
    – whuber
    Feb 10 '11 at 22:26
  • $\begingroup$ @HawkEgg There is uncertainty about how good either John or Mike are. E.g., if Mike makes 2/3 shots and John makes 8/11 shots, the estimated probability for each is 3/4 (assuming uniform priors for each), but the chance that John is better than Mike is only 165/364 = 45.3% because there's a good chance Mike is a superb shooter (and got unlucky once) whereas we have a fairly good idea how good John is (because he has taken more shots). $\endgroup$
    – whuber
    Feb 10 '11 at 22:32
  • $\begingroup$ @whuber Are you saying that Mike, who made a lower % of shots than John, has a 54.7% chance of being better than John? That doesn't pass my sniff test. Could you give me some more details on how you calculated the 3/4 and 45.3% numbers? A reference? $\endgroup$ Feb 11 '11 at 1:15
  • $\begingroup$ @HawkEgg if you'd like to know who has the higher free throw percentage than you can compare the posterior distributions instead of the predictive. That is, you can compare a Beta(a0 + shots made, b0 + shots missed) for each player. $\endgroup$
    – Nick
    Feb 11 '11 at 2:17

This is very much a problem in Bayesian inference. You appear to have taken the first step in realizing that the sample is not the same as the underlying probability distribution. Even though Mike had a higher mean in his sample, John might have a higher mean for his true talent distribution. When applying Bayesian inference, we start with a prior distribution, use the evidence to update our knowledge, and come out with a posterior distribution.

The point I alluded to in my comment is that the prior knowledge can matter a great deal. If we happen to know that the "John" happens to be basketball Hall of Famer John Stockton and the "Mike" happens to be me, then 100 shots are not going to be nearly enough to convince you that I'm better. You prior distribution for John Stockton's true talent would probably be somewhat tight with a mean near .8 or so (he was .8261 for his career), whereas who knows for me...it might be .3 for all I know.

If you are estimating the true talent probabilities of making a free throw, you at least know that the values must lie in (0, 1), so a minimal prior distribution for each would be the uniform probability distribution on (0, 1). This is equivalent to using the Beta distribution with parameters $\alpha = \beta = 1$. Through some calculations I won't get into (along with Bayes theorem), it turns out that the posterior distribution is also a Beta distribution with parameters $\alpha + i$ and $\beta + j$ (assuming the player made $i$ shots in $i + j$ attempts).

So our posterior distribution for John is $Beta(39, 13)$ and for Mike it is $Beta(81, 21)$. So with these priors our posterior estimate of John's mean talent is $\frac{39}{52} = .75$ and for Mike it is $\frac{81}{102} \approx .794.$ I believe finding the answer to how likely Mike is better in a nice closed form is messy, and I don't have the tools handy to calculate the exact answer, but you would integrate/sum the portions of those curves where Mike is better to find the answer. Nick's code looks like it will probably get you a nice approximation. I can tell you that with the prior I chose Mike will be higher (since they had the same prior and Mike had the higher sample mean, it does pass the smell test that Mike will have a higher posterior mean).


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.