Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: zeros in the Gamma distribution.


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: zeros in the Gamma distribution.
Date   Thu, 8 Apr 2010 01:47:40 -0700 (PDT)

--- On Thu, 8/4/10, sun samn wrote:
>    As we all know, the random numbers from Gamma
> distributions should be positive; but when I use 'rgamma' to
> generate 100 numbers, it has 7 zeros, why is that? Is this
> reasonable? is there any way to get rid of these zeros? 
>    You know ,I need to take log of these numbers, the
> zeros are really bothering me.

It means you are trying to use a too extreme distribution. 
Basically the numbers become so small that a computer cannot
distinguish them from zero. Things become better when you
create the variable as doubles, but it still finds a substantial
number of zeros in the most extreme distribution. But looking at
these distributions you can see that they cannot possible serve
any practical purpose: to all intends and purposes they are so
extreme that in a real data situaton there would be no way of
distinguishing this distribution form a spike at zero and a small 
scattering of other values.

*-------- example using floats ------------
clear
set obs 10000
gen x1 = rgamma(1,1)
count if x1 == 0
gen x2 = rgamma(.1,1)
count if x2 == 0
gen x3 = rgamma(.01,1)
count if x3 == 0
gen x4 = rgamma(.001,1)
count if x4 == 0
*------------ end example ------------------

*----------- example using doubles ------------
clear
set obs 10000
gen double x1 = rgamma(1,1)
count if x1 == 0
gen double x2 = rgamma(.1,1)
count if x2 == 0
gen double x3 = rgamma(.01,1)
count if x3 == 0
gen double x4 = rgamma(.001,1)
count if x4 == 0
*-------------- end example -----------------

-- Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl
--------------------------


      

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index