# 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 at 3:09 Incidentally, that's the formula for the variance, not the standard deviation- which is .18? – David Robinson Jan 17 at 3:18 I added the missing ^2 above. – Dimitriy V. Masterov Jan 17 at 18:11

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 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 at 15:02 I am impressed that your eyeballing was this accurate. – Dimitriy V. Masterov Jan 19 at 1:03