What are the advantages of an exponential random generator using the method of Ahrens and Dieter (1972) rather than by inverse transform? My question is inspired by R's built-in exponential random number
  generator, the function rexp().
  When trying to generate exponentially distributed random numbers,
  many textbooks recommend the inverse transform method as outlined in  this Wikipedia page.
  I am aware that there are other methods to accomplish this task. In
  particular, R's source code uses the algorithm
  outlined in a paper by Ahrens & Dieter (1972).
I have convinced myself that the Ahrens-Dieter (AD) method is
  correct. Still, I do not see the benefit of using their method
  compared to the inverse transform (IT) method. AD is not only more
  complex to implement than IT. There does not seem to be a speed
  benefit either. Here is my R code to benchmark both methods
  followed by the results.
invTrans <- function(n)
    -log(runif(n))
print("For the inverse transform:")
print(system.time(invTrans(1e8)))
print("For the Ahrens-Dieter algorithm:")
print(system.time(rexp(1e8)))

Results: 
[1] "For the inverse transform:" 
user     system     elapsed
4.227    0.266      4.597 
[1] "For the Ahrens-Dieter algorithm:"
user     system     elapsed
4.919    0.265      5.213

Comparing the code for the two methods, AD draws at least two
uniform random numbers (with the C function unif_rand()) to
get one exponential random number. IT only needs one uniform
random number.
Presumably the R core team decided against implementing IT
because it assumed that taking the logarithm may be slower than
generating more uniform random numbers. I understand that the
speed of taking logarithms can be machine-dependent, but at least
for me the opposite is true.
Perhaps there are issues around IT’s numerical precision having to
do with the singularity of the logarithm at 0? But then, the R
source code sexp.c reveals that the implementation of AD also loses
some numerical precision because the following portion of C code
removes the leading bits from the uniform random number u.
double u = unif_rand();
while(u <= 0. || u >= 1.) u = unif_rand();
for (;;) {
    u += u;
    if (u > 1.)
        break;
    a += q[0];
}
u -= 1.;

u is later recycled as a uniform random number in the remainder
of sexp.c.
So far, it appears as if


*

*IT is easier to code,

*IT is faster, and

*both IT and AD possibly lose numerical accuracy.


I would really appreciate if someone could explain why R still
implements AD as the only available option for rexp().
 A: This is just quoting the article under the "Algorithm LG: (Logarithm method)" section :

In FORTRAN the algorithm is best programmed directly as
  $X=-ALOG(REGOL(IR))$ avoiding any subprogram call. The performance was
  504 $\mu$sec per sample. Of this time 361 $\mu$sec was taken up by the
  manufacturer's logarithm routine and 105 $\mu$sec by the generator for
  REGOL of the uniformly distributed variable $u$. Therefore there was
  no point in trying to improve speed by writing an assembler function
  which would have to use the same two subprograms.

So it looks like the authors opted for other methods to avoid this "manufacturer" limitation of slow logarithms. Perhaps this question is then best moved to stackoverflow where someone with knowledge on the guts of R can comment. 
A: Just running this with microbenchmark; on my machine, R's native approach is uniformly faster:
library(microbenchmark)
microbenchmark(times = 10L,
               R_native = rexp(1e8),
               dir_inv = -log(runif(1e8)))
# Unit: seconds
#      expr      min       lq     mean   median       uq      max neval
#  R_native 3.643980 3.655015 3.687062 3.677351 3.699971 3.783529    10
#   dir_inv 5.780103 5.783707 5.888088 5.912384 5.946964 6.050098    10

For novelty's sake, here's making sure it's not entirely due to having $\lambda = 1$:
lambdas = seq(0, 10, length.out = 25L)[-1L]
png("~/Desktop/micro.png")
matplot(lambdas, 
        ts <- 
          t(sapply(lambdas, function(ll)
            print(microbenchmark(times = 50L,
                                 R_native = rexp(5e5, rate = ll),
                                 dir_inv = -log(runif(5e5))/ll),
                  unit = "relative")[ , "median"])),
        type = "l", lwd = 3L, xlab = expression(lambda),
        ylab = "Relative Timing", lty = 1L,
        col = c("black", "red"), las = 1L,
        main = paste0("Direct Computation of Exponential Variates\n",
                      "vs. R Native Generator (Ahrens-Dieter)"))
text(lambdas[1L], ts[1L, ], c("A-D", "Direct"), pos = 3L)
dev.off()


