# Translated Exponential Distribution

The first thing I did on this Day of Independence was run a 5k in Brighton, NY. I was quite happy with the result. As someone who has only recently learned how to run intelligently (regardless of the fact that I thought I knew how to run), I’m beginning to see my average pace get faster and faster. And, this is rewarding.

But who titles a post about running “Translated Exponential Distribution”? Not even me. So, let’s move on.

The second thing I did today was fix some C++ code for random number generation from a Truncated Normal Distribution. The naive Accept-Reject algorithm is great in some cases and terrible in others. None of the R packages that offered an implementation really met my needs, so I implemented the sampler described in Robert (1995) (gated).

Although there is an R interface for my own end-use, everything important happens in C++ via Rcpp. For some parameter settings (see the paper, of course), the algorithm calls for simulating from a Translated Exponential distribution. Personally, I’d never come across this distribution (which maybe should be a point of embarrassment?). Google wasn’t terribly helpful, although I probably could have derived the solution if I felt so inclined. But, that’s more work than the problem really merits given the simplicity of the relationship.

## Easy Simulation

Let $x$ be an Exponential random variable such that $x$ has the density $$f(x) = \exp(-x) * \mathbf{I}_{~x \geq 0}.$$ Then $y = \mu + \frac{x}{\lambda}$ has the density

$$g(y| \mu, \lambda) = \lambda * \exp(–\lambda(y – \mu)) * \mathbf{I}_{~x \geq \mu}$$

and $y$ is said to be a Translated Exponential random variable with scale parameter $\lambda$ and shift parameter $\mu$.

For simulation purposes, $y = \mu + \frac{x}{\lambda}$ is what matters. First, simulate $x$ from an exponential distribution. Second, transform $x$ to produce $y$. Quite simple as far as these things go.