Diff for "FAQ/gamma" - CBU statistics Wiki
location: Diff for "FAQ/gamma"
Differences between revisions 8 and 9
Revision 8 as of 2008-02-12 17:32:11
Size: 1125
Editor: PeterWatson
Revision 9 as of 2008-02-12 17:32:51
Size: 1099
Editor: PeterWatson
Deletions are marked like this. Additions are marked like this.
Line 20: Line 20:
compute sum=0.

How do I produce random variables which follow a negatively skewed distribution?

Most distributions such as the exponential and log-Normal distributions are positively skewed with the mode of the distribution occurring for lower values.

The Gamma distribution [http://www.aiaccess.net/English/Glossaries/GlosMod/e_gm_gamma_distri.htm: may be produced by summing exponential distributions.] There are two parameters, n and $$\lambda$$. n is the number of summed exponentials and $$\lambda$$ is the exponential rate. When $$\lambda$$ is very small compared to n a negative skewed version of the gamma distribution results with no upper limit.

The below produces two exponential random variables (n=2) with a very small $$\lambda$$ (=1/10000) in SPSS and sums them. One resulting simulated data set produced using this macro had a skew of -1.03.

define !gamma ( !pos !tokens(1)
                /!pos !tokens(1)).
!do !i=!1 !to !2 !by 1.
compute !concat(a,!i)=-(10000)*ln(rv.uniform(0,1)*10000).

!gamma 1 2.

compute sum=-(a1+a2).

None: FAQ/gamma (last edited 2013-03-08 10:17:36 by localhost)