Thanks for reporting back.
The quantity to measure is effective sample size per second, not just
iteration speed.
Various reparameterizations affect both iterations per second or
effective samples per iteration, and it's the net effect that matters.
- Bob
On Mar 12, 2014, at 9:23 PM, Herra Huu <
heikki.uu...@gmail.com> wrote:
> Simplex transformation doesn't seem to do that much here, in fact I think the sampling become even a bit slower. But using reparameterizations "tricks" for multivariate normal distribution (p. 182-183 in Stan manual) did help a lot (about 4s / 2000 samples compared to 100s with the original model). I'm still learning about Gaussian processes, so I'm not 100% sure if the model is correct though (results seems to be ok). But anyway, here is the code:
>
> stan_code <- 'data {
> int<lower=1> N; // number of bins
> vector[N] x; // bin centers
> int<lower=0> y[N]; // number of observations per bin
> }
> parameters {
> real<lower=0> ms2; // magnitude of GP
> real<lower=0> l; // lengthscale of GP
> real b1; // mean function parameter
> real<lower=0> b2; // mean function parameter
> vector[N] alpha;
> }
> transformed parameters {
> vector[N] mu;
> vector[N] log_p;
> matrix[N,N] L;
> matrix[N,N] Sigma;
>
> mu <- b1*x - b2*x .* x;
> for (i in 1:N)
> for (j in 1:N)
> {
> Sigma[i,j] <- ms2*exp(-pow(x[i] - x[j],2)/l) + if_else(i==j, 0.0001, 0.0);
> Sigma[j,i] <- Sigma[i,j];
> }
> L <- cholesky_decompose(Sigma);
> log_p <- log_softmax(mu + L * alpha);
> }
> model {
> alpha ~ normal(0,1);
>
> // priors for covariance function parameters
> ms2 ~ student_t(4,0,10);
> l ~ student_t(4,0,4);
>
> // log-prob
> for (n in 1:N)
> increment_log_prob(y[n]*log_p[n]);
> }'
>
> --
> You received this message because you are subscribed to the Google Groups "stan users mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
stan-users+...@googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.