Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

RE: st: zeros in the Gamma distribution.


From   sun samn <shwshang@hotmail.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: zeros in the Gamma distribution.
Date   Fri, 9 Apr 2010 15:41:23 +0800



Maarten,

  Thank you very much! Double does reduce zeros, but it cannot exclude them!
samn 







----------------------------------------
> Date: Thu, 8 Apr 2010 01:47:40 -0700
> From: maartenbuis@yahoo.co.uk
> Subject: Re: st: zeros in the Gamma distribution.
> To: statalist@hsphsun2.harvard.edu
>
> --- 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/
 		 	   		  
_________________________________________________________________
Hotmail: Powerful Free email with security by Microsoft.
https://signup.live.com/signup.aspx?id=60969
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index