Random increment through a probability distribution function

515 Views Asked by At

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

2

There are 2 best solutions below

1
On BEST ANSWER

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);
2
On

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.