# Bayesian batting average prior

I wanted to ask a question inspired by an excellent answer to the query about the intuition for the beta distribution. I wanted to get a better understanding of the derivation for the prior distribution for the batting average. It looks like David is backing out the parameters from the mean and the range.

Under the assumption that the mean is $0.27$ and the standard deviation is $0.18$, can you back out $\alpha$ and $\beta$ by solving these two equations: $$\frac{\alpha}{\alpha+\beta}=0.27 \\ \frac{\alpha\cdot\beta}{(\alpha+\beta)^2\cdot(\alpha+\beta+1)}=0.18^2$$

-
Honestly, I just kept graphing values in R until it looked right. – David Robinson Jan 17 '13 at 3:09
Incidentally, that's the formula for the variance, not the standard deviation- which is .18? – David Robinson Jan 17 '13 at 3:18
I added the missing ^2 above. – Dimitriy V. Masterov Jan 17 '13 at 18:11
where do you get the standard deviation to be .18? – appleLover Jul 20 '13 at 19:20

Notice that:

$$\frac{\alpha\cdot\beta}{(\alpha+\beta)^2}=(\frac{\alpha}{\alpha+\beta})\cdot(1-\frac{\alpha}{\alpha+\beta})$$

This means the variance can therefore be expressed in terms of the mean as

$$\sigma^2=\frac{\mu*(1-\mu)}{\alpha+\beta+1} \\$$

If you want a mean of $.27$ and a standard deviation of $.18$ (variance $.0324$), just calculate:

$$\alpha+\beta=\frac{\mu(1-\mu)}{\sigma^2}-1=\frac{.27\cdot(1-.27)}{.0324}-1=5.083333 \\$$

Now that you know the total, $\alpha$ and $\beta$ are easy:

$$\alpha=\mu(\alpha+\beta)=.27 \cdot 5.083333=1.372499 \\ \beta=(1-\mu)(\alpha+\beta)=(1-.27) \cdot 5.083333=3.710831$$

You can check this answer in R:

> mean(rbeta(10000000, 1.372499, 3.710831))
[1] 0.2700334
> var(rbeta(10000000, 1.372499, 3.710831))
[1] 0.03241907

-
David, do you happen to follow any baseball research? There are several competing techniques out there for finding the proper $\alpha$ and $\beta$, so I was wondering if you had any opinion on the matter if you were doing something besides just trying to find a graph that looked reasonable. – Michael McGowan Jan 17 '13 at 14:53
I don't particularly follow sabermetrics- in the other answer it just happened to provide a very convenient example of estimating p from a binomial with a prior. I don't even know if this is how it's done in sabermetrics, and if it is, I know there are many components I left out (players having different priors, stadium adjustments, weighting recent hits over old ones...) – David Robinson Jan 17 '13 at 15:02
I am impressed that your eyeballing was this accurate. – Dimitriy V. Masterov Jan 19 '13 at 1:03
Hi David, how do you get from these values of $\alpha = 1.37$ and $\beta = 3.71$ to your eyeballed values in the linked post of 81 and 219 respectively? – Alex Feb 29 at 2:15
@Alex The requested variance and standard deviation come from the above question, which asked for an SD of .18, not the beta distribution post. If I were calculating instead of eyeballing I might have guessed an SD of something like .03, which would have given values of 59 and 160. – David Robinson Feb 29 at 2:32