I want to use Stan for long running, resource heavy MCMC simulations (QFT on the lattice).
After playing around with it for a few hours, I managed to run a trivial Monte-Carlo simulation (computing the first 5 powers of x where x is uniform within [0 \dots 1]).
Here’s the code:
data {
int N;
}
parameters {
real x;
}
model {
x ~ uniform(0, 1);
}
generated quantities {
real pow[N];
for (i in 1:N)
pow[i] = x^i;
}
When I run this simulation by running ./simulation sample data file=input.json
, it produces the CSV output containing 1000 samples.
Instead, I would like it to display the expected values of the powers of x (\left< x^n \right> = \frac{1}{n + 1}) and estimated errors.
Now I can always get that information from the sample, in a post-processing phase. But if I am to run simulations in parallel for days, they would produce an enormous number of samples, for which I don’t have enough storage.
Can I somehow instruct Stan to not keep the samples in memory and not write them to disk, but only keep the expectation values and estimated errors?