Prior Gamma distribution: Select appropriate alpha given beta and median I am trying to programatically select a prior distribution from the Gamma family of distributions. The primary criteria that I need to satisfy is that the median of the distribution should be a given value $X$ (i.e. such that it's equally probable to have a parameter value above $X$ or below $X$)
Additionally, because I'm using the distribution as a conjugate prior for a Poisson distribution's lambda, and I know how much relative weight I want to give to the prior relative to the subsequent observations, I think I know what an appropriate $\beta$ parameter is (though I could be wrong on this point, feel free to make comments if I'm thinking about that incorrectly).
So essentially my problem becomes how to select an appropriate $\alpha$ such that the median is $X$. The way I've considered this seems to work well to get a good prior distribution when constraining the mean (or even mode), but technically, I should be constraining the median. Is this possible formulaicly, or would I need to resort to some kind of computational search to find the right value?
 A: Much about your question is unclear, but I can talk about the median in the gamma distribution and you may be able to resolve the problem from that.
The gamma distribution is typically written either in the rate form or the scale form (I'll avoid using $\beta$ here, since your intention isn't clear):
Rate form:
$$f(x;\alpha,\phi) = \frac{\phi^\alpha}{\Gamma(\alpha)} x^{\alpha-1}e^{-\phi x} \quad \text{ for } x > 0 \text{ and } \alpha, \phi > 0$$
Scale form:
$$f(x;\alpha,\theta) =  \frac{x^{\alpha-1}e^{-\frac{x}{\theta}}}{\theta^\alpha\Gamma(\alpha)} \quad \text{ for } x > 0 \text{ and } \alpha, \theta > 0$$
It's sometimes also written in the mean form (especially for GLMs):
$$f(x;\alpha,\mu) = \frac{\alpha^\alpha}{\mu^\alpha\Gamma(\alpha)}x^{\alpha-1}e^{-\frac{x\alpha}{\mu}} \quad \text{ for } x > 0 \text{ and } \alpha, \mu > 0$$
--
The mean is $\alpha\theta = \alpha/\phi=\mu$.
The median doesn't have a simple closed form, but for larger $\alpha$, it can be approximated.
For $\beta=1$, for large $\alpha$, the median is approximately the mean $-\frac{1}{3}$. This works well for $\alpha$ around 10 and higher.

More accurately, the median is approximately $\frac{3 \alpha - 0.8}{3 \alpha + 0.2}$ times the mean (as long as $\alpha$ is not too small, say no less than somewhere around 1-2, it works okay):

Another way to approach the median is via the Wilson-Hilferty transformation; since the cube root of a gamma is approximately normal, one can approximate the relationship between the mean and the median via that relationship (the median directly transforms both directions, but the mean is more complicated - one can use Taylor expansions to approximate the mean). (Examination of this approximation suggests it's actually pretty poor. The Wikipedia page uses it to approximate the median for the chi-square distribution, but frankly it looks like it's not nearly as good as even the "$-\frac{1}{3}$" rule I mentioned earlier, let alone the other one.)
For more accuracy, if one specifies the median and one specifies the scale or rate parameter, one can use the gamma cdf or the inverse gamma cdf (the gamma quantile function) to iteratively solve for the required alpha.
If $F$ is the gamma cdf and $F^{-1}$ is its inverse, you use root finding to solve $F_{\alpha,\beta}(m) - \frac{1}{2}=0$ for $\alpha$, or to solve $m - F^{-1}_{\alpha,\beta}(\frac{1}{2})=0$
A good starting point would be from one of the previously mentioned approximations.

I think I know what an appropriate β parameter is (though I could be wrong on this point, feel free to make comments if I'm thinking about that incorrectly)

It's a bit hard to comment about whether you have a misconception here if you aren't explicit about what you actually think and why.
A: Based on testing a large number of possible medians $X$, and the formula I was using to select beta as $\beta = 1/X$, it seems that alpha is constant: $\alpha \approx 1.314250$ . I still don't know the formula for this result, but for my programmatic needs, it's sufficient.
