A Maxwell-Boltzmann distribution, written as a Gamma distribution Introduction
I have read that a Maxwell-Boltzmann distribution can be written equivalently as a Gamma distribution, however I have not managed to find or derive the parameters used to do so.
The form I would like to produce is for the total energy of a particle.
$$
f_{E}(E)=2{\sqrt {{\frac {E}{\pi }}}}\left({\frac {1}{kT}}\right)^{{3/2}}\exp \left({\frac {-E}{kT}}\right) 
$$
So my question is: I would like to find the shape parameter $\alpha$, and the inverse scale parameter $\beta$ of the Gamma distribution which will generate a Maxwell-Boltzmann distribution, from which I can sample energy values.
Derivation
One approach I tried, was to look at the mean, $ \alpha / \beta $, and the mode, $ \alpha - 1 / \beta $ of the Gamma distribution, and to solve two simultaneous equations by equating to corresponding expected  energy values. The main issue that arose is that it produced a negative $\alpha$, which is undefined for the Gamma distribution.
Thanks for any help!
 A: Just compare two formulae:
$$
{\displaystyle f(x) ={\frac {\beta ^{\alpha }}{\Gamma (\alpha )}}x^{\alpha -1}e^{-\beta x}},\qquad f(E)=2{\sqrt {{\frac {E}{\pi }}}}\left({\frac {1}{kT}}\right)^{{3/2}}\exp \left({\frac {-E}{kT}}\right).
$$
We can see that $\beta=\frac1{kT}$ and $\alpha=\frac32$.
Your confusion may arise from the fact that besides parameters $\alpha,\beta$ (shape, rate) for gamma distribution, parameters $\alpha,\theta$ (shape,scale) are also widely used ($\theta=1/\beta$). What adds to the confusion, is that scale parameter is often denoted as $\beta$ as well. So seeing just the value of $\beta$ one can never be sure what it really means and needs to refer to documentation. In particular, the function std::gamma_distribution used in your link has the exact this issue (although they admit that the notation is not universal):

In other words parameters to put into std::gamma_distribution should be $\alpha=3/2$ and $\beta=kT$ ($\theta=kT$).
A: No modification needs to be made.
The parametrisation has shape parameter
$\alpha = \frac{3}{2}$, and scale parameter
$\theta = kT$. So the rate parameter is $\beta = \frac{1}{kT}$.
This can be verified by looking at the form of the PDF for the Gamma distribution:
$$
f(x; \alpha, \beta) = \frac{1}{\Gamma(\alpha)}{\beta}^{\alpha}{x}^{\alpha}{e}^{- \beta x}
$$
Then we have:
$$
\Gamma(\alpha = 1.5) = \frac{\sqrt{\pi}}{2}
$$
$$
{\beta}^{\alpha} = {(\frac{1}{kT})}^{\frac{3}{2}}
$$
$$
{x}^{\alpha - 1} = {E}^{\frac{1}{2}}
$$
Which reproduces the Maxwell-Boltzmann distribution exactly:
$$
f_{E}(E)=2{\sqrt {{\frac {E}{\pi }}}}\left({\frac {1}{kT}}\right)^{{3/2}}\exp \left({\frac {-E}{kT}}\right) 
$$
