# Random increment through a probability distribution function

To Clarify i am trying to generate a random variable from a gamma pdf

If $\Delta X$ indicates a random increment and it is said that $\Delta X$ follows a Gamma distribution.

What would that mean exactly? How would you be able to get random variables from the Gamma distribution?

So far I understood the following, but am guessing this might be wrong:

$$X\sim \Gamma(\alpha,\beta)\equiv\operatorname{\Gamma}(\alpha,\beta)$$

This means $X$ follows a Gamma distribution so $\Delta X$ is a kind of sum of the different values $X$ takes at every iteration

$$g(x;\alpha, \beta) = \frac{\beta^\alpha x^{\alpha-1}e^{-x\beta}}{\Gamma(\alpha)}, \text{ for } x\geqslant 0\text{ and } \alpha,\beta>0$$

so $X$ is represented by $x$ in the Gamma pdf, meaning I should put the value of $X$ for $x$ when computing the value of $X$ from the Gamma pdf?

https://en.wikipedia.org/wiki/Gamma_distribution

• What do you call "computing the value of X from the Gamma pdf"? One does not "compute the value" of a random variable...
– Did
Jul 24, 2015 at 15:04
• @Did Sure you can! Given $\omega\in\Omega$, one can compute the value of e.g. $X(\omega)$ (granted this is only possible if the function $X:\Omega\to\mathbb R$ is defined explicitly instead of in terms of its distribution). Jul 24, 2015 at 15:52
• @Math1000 Thanks for your comment. Is it related to the present page?
– Did
Jul 24, 2015 at 15:53
• I was being facetious re: "One does not "compute the value" of a random variable" :) Jul 24, 2015 at 15:57
• @Math1000 No problem, I might be too slow...
– Did
Jul 24, 2015 at 17:35

It sounds like you want to generate gamma-distributed random variables. If you want to write the code yourself, the way I know how is using the acceptance-rejection method by first generating an exponentially-distributed RV. An exponential random variable $G$ with pdf $\lambda \mathrm e^{-\lambda g}$ may be generated by first generating a uniform(0,1) random variable $U$ and applying the inverse transformation $$G = -\frac{1}{\lambda}\log(1-U).$$ To generate a $gamma(\alpha,\beta)$-ditributed random variable, choose $\lambda = \frac{\alpha}{\beta}$ above and then use the acceptance-rejection method.

OTOH most scientific software includes these methods. E.g. MATLAB's gaminv(p,a,b) could be used where $p$ is a uniform(0,1), $a = \alpha$ and $b = \frac{1}{\beta}$ (MATLAB uses the "other" version of the pdf you've given). For example if you want to generate $1000$ gamma(2,3) random variables:

a=2;
b=1/3;
n=1000;
u=rand(n,1);
g=gaminv(u,a,b);

• Perhaps see http://math.stackexchange.com/questions/1635250/ for more on acc-rej method. Feb 1, 2016 at 17:38

If $F$ is the pdf of the Gamma distribution with the correct parameters then for all real $x$, $$\Pr[\Delta X < x] = F(x).$$ This defines the distribution of $\Delta X$ completely.

• Thank you for the answer but I dont know if i understood the answer, how do you define x ? ∆X should be random so should there be a random process for defining x, i am sorry if i dont get it, could you explain in more depth ? Jul 24, 2015 at 14:55
• I'm not defining $x$. The equation is true for all $x$. For example, the probability that $\Delta X$ is at most $10$ is $F(10)$. Jul 24, 2015 at 14:55