(Mis)understanding reparameterization of the double-exponential distribution

Hey everyone,

I’ve been playing around with the double-exponential distribution, and I am struggling to understand how the non-centered parameterization works. When I simulate from the following chunk, I get very different distributions for the centered vs non-centered parameterizations. They have the same means, but the standard deviation for the non-centered version is 7-8x the centered version. I imagine this is due to a fundamental misunderstanding on my part, what is it?

Here’s the link to the double-exponential in the Stan reference:

Thanks for your help!
Josh

data{}
model{}
generated quantities {
    real mu = normal_rng(0, .5);
    real<lower=0> sigma = exponential_rng(1);
    real centered = double_exponential_rng(mu,sigma);
    real a = exponential_rng(1/(2*(sigma^2)));
    real b_raw = normal_rng(0,1);
    real non_centered = mu + a * b_raw;
}

Hi Josh,
mu and sigma are the model parameters and are fixed (for simulation purposes). For example define mu = 1 and sigma = 1. Simulate using the double_exponential_rng function.

Then compare that to the alternative way to generate the follow the steps in the link that you shared (i.e. simulate from a normal and simulate alpha from an exponential distribution).
@Bob_Carpenter: I think that there is a typo in the manual at 19.7 Double exponential (Laplace) distribution | Stan Functions Reference (mc-stan.org). We require the square root of alpha (I checked this by simulation in R).

Beta = mu + sqrt(alpha)*Beta_raw

sigma <- 1
mu <- 10
n_sim <- 1000000
alpha <- rexp(n_sim, 1/(2*(sigma^2)))
beta <- mapply(rnorm, n = 1,mean = mu, sd  = sqrt(alpha))
dens1 <- density(beta)

beta_raw <- rnorm(n_sim)
plot(density(mu +(sqrt(alpha)*beta_raw)), col = "red")
lines(dens1$x, dens1$y)

1 Like

Thank you! By replacing a, with sqrt(a), in the stan model above, the non-centered parameterization seems to be producing the same distribution as the double exponential function.
I appreciate the help!
Josh

1 Like

PR on the doc typo here Fixing typo in non-centered double exponential by jsocolar · Pull Request #672 · stan-dev/docs · GitHub

1 Like