Introduction
I was needed to provide different methods to generate samples from gamma distribution with different shape(\(\alpha\)) parameters and scale(\(\lambda\)) parameter equal to one. There are few algorithms with the condition of \(0<\alpha<1\). I needed to generate random variables from \(\alpha>1\), hence I have generated random variables for the integer part of \(\alpha\) using inverse of exponential distribution and for the fractional part using different algorithms based on Acceptance-Rejection method. There are algorithms with condition of \(\alpha>1\), in those case I have directly implemented the algorithms to get random variables. I have then used the obtained variables to plot density graph as it gave better information about the distribution than histograms and compared it with actual graph obtained using standard library in R. I have observed and reported the running time of the algorithms and the amount of rejection in generating random variables using different algorithms for different \(\alpha\). I have presented the graphs that I found gave the most accurate fit with better efficiency.
Methods
Algorithm GT(two-part method)\citep*{Ahrens1974}:
This method divides \(\alpha\) into its integer(m) and fractional(f) part. The integer part is generated by adding up random variables generated from exponential distribution, m times and then adding up it with random variable generated for the fractional part(f) using Algorithm GS for \(0 \leq \alpha \leq 1\). Algorithm GS uses acceptance-rejection method with the following majorization function.