0
$\begingroup$

I read in Chapter 6 in this book that

$p(K)\propto 1$ is equivalent to $e^{-K}\sim Gamma(0,0)I(0,1)$

where $K$>0 and is uniform distribution, e.g., $K \sim Uniform(0,100)$; $I(a,b)$ is the truncated distribution to represent interval censoring, whose sole effect is to ensure that all values sampled outside the specified interval are rejected.

I tried the WinBUGS code to find if this statement is true:

model{
    # use a small number '0.03' instead of '0', or the program will crash
    exp.ngK ~ dgamma(0.03, 0.03)I(0,1)
    K <- -log(exp.ngK)
}

I run the iteration for 1,000,000 times. Unfortunately, $K$ is not a uniform distribution (see left panel in Fig.1 below). Why does this happen?

Fig.1

Update:

According to @whuber♦ comment, I tried $Gamma(1,1)I(0,1)$ for exp.ngK. However, K seems not a uniform distribution in [0,1] (see left panel in Fig.2, it has a peak). Since I have made one million iterations, I guess K may be not uniform?

Fig.2

$\endgroup$
  • 1
    $\begingroup$ Because "Gamma(0,0)" is nonsense, you have to be careful about interpreting it. Try plotting, say, curve(ifelse(x < 1, dgamma(x,1,1e-4)*1e4, 0), 0, 1.1, n=501): that produces a uniform distribution. However, that doesn't even seem to be what the quotation says: it claims that the negative log of a uniformly distributed variable has a "Gamma(0,0)" distribution. It doesn't: it has a Gamma(1,1) distribution. $\endgroup$ – whuber Jul 11 at 15:42
  • $\begingroup$ @whuber I tried gamma(1,1)I(0,1). However, K seems not uniform. See "Update" in my post $\endgroup$ – T X Jul 12 at 2:01
  • $\begingroup$ I'm sorry: in my haste I got it backwards. When you exponentiate an exponential variate you get a uniform. E.g., the R command hist(exp(-rexp(1e6))) will display a histogram of a million realizations and this histogram will be clearly uniform. It's unclear what you're trying to accomplish, though, since there are much easier ways to generate uniform random numbers! $\endgroup$ – whuber Jul 12 at 2:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.