# 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: \begin{equation} \frac{\alpha}{\alpha+\beta}=0.27 \\ \frac{\alpha\cdot\beta}{(\alpha+\beta)^2\cdot(\alpha+\beta+1)}=0.18^2 \end{equation}

-

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

## 1 Answer

Notice that:

\begin{equation} \frac{\alpha\cdot\beta}{(\alpha+\beta)^2}=(\frac{\alpha}{\alpha+\beta})\cdot(1-\frac{\alpha}{\alpha+\beta}) \end{equation}

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

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

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

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

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

\begin{equation} \alpha=\mu(\alpha+\beta)=.27 \cdot 5.083333=1.372499 \\ \beta=(1-\mu)(\alpha+\beta)=(1-.27) \cdot 5.083333=3.710831 \end{equation}

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
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 11, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.8462719321250916, "perplexity_flag": "middle"}