I got the following gamma function: $\frac{B^{a}}{\Gamma(a)}x^{a-1}\ e^{-Bx}\ I_{[0,\infty)}(x)$
I would like to derive the raw moments and thus the variance but I know that I must have made a mistake somewhere because I do not get the same variance as wikipedia states https://en.wikipedia.org/wiki/Gamma_distribution. $E[X^{k}]= \frac{B^{a}}{\Gamma(a)} \int_{0}^{\infty} x^{k+a-1}e^{-Bx}dx \mid
I can plug this in above and derive the first and second raw moment. I get the same first raw moment as in wikipedia https://en.wikipedia.org/wiki/Gamma_distribution but if I derive the second raw moment and if I use this second raw moment to compute the variance I get a wrong expression for the variance. What did I wrongly and how can I find the function for all raw moments? We haven't used moment generating functions in class so far. Hence, I would appreciate it if you do not bring up any solution related to moment generating functions.
Thank you very much.
If you accept that the integral of a gamma density over its support is equal to $1$ for any choice of shape and rate parameters $a$ and $b$, that is to say, $$\int_{x=0}^\infty f_X(x) \, dx = \int_{x=0}^\infty \frac{b^a x^{a-1} e^{-bx}}{\Gamma(a)} \, dx = 1, \tag{1}$$ then calculating the raw moments is straightforward: we have
$$\begin{align} \operatorname{E}[X^k] &= \int_{x=0}^\infty x^k f_X(x) \, dx \\ &= \int_{x=0}^\infty \frac{b^a x^{a+k-1} e^{-bx}}{\Gamma(a)} \, dx \\ &= \frac{\Gamma(a+k)}{\Gamma(a) b^k} \int_{x=0}^\infty \frac{b^{a+k} x^{a+k-1} e^{-bx}}{\Gamma(a+k)} \, dx. \tag{2} \end{align}$$
What we have done is rewritten the integrand in terms of a gamma density with shape parameter $a+k$ and rate $b$ by observing what factors that are constant with respect to $x$ are needed in the integrand. Therefore, the resulting integral equals $1$ and we get $$\operatorname{E}[X^k] = \frac{\Gamma(a+k)}{\Gamma(a) b^k}. \tag{3}$$
This formula applies whenever the integral in $(2)$ is convergent, which occurs whenever the shape parameter $a+k$ is positive; therefore, $(3)$ is valid for any $k > -a$.
When $k$ is an integer, the expression $\Gamma(a+k)/\Gamma(a)$ simplifies; e.g., $$\operatorname{E}[X] = \frac{a}{b}, \\ \operatorname{E}[X^2] = \frac{a(a+1)}{b^2}, \\ \operatorname{E}[X^3] = \frac{a(a+1)(a+2)}{b^3},$$ and so forth.
In closing, the validity of $(1)$ can also be established by a suitable variable substitution of the gamma function identity $$\Gamma(a) = \int_{z=0}^\infty z^{a-1} e^{-z} \, dz. \tag{4}$$ We simply let $z = bx$, hence $dz = b \, dx$, from which we obtain $$\Gamma(a) = \int_{x=0}^\infty (bx)^{a-1} e^{-bx} b \, dx = \int_{x=0}^\infty b^a x^{a-1} e^{-bx} \, dx$$ for $b > 0$, and dividing by $\Gamma(a)$ yields $(1)$.