Using Stan for non-modelling purposes

Is it possible to use Stan for non-modelling purposes, i.e. for other things than estimating parameters in a model?
For example, generating draws from some distribution, convex optimization problems given data, numerical integration etc.
If yes, how?


yes, this can and should be done. here’s a nice blog post showing you how to do it:


Thanks for this!

I see how this works for drawing samples from posterior, but what about using Stan for optimization and numerical integration?

if I understand your question correctly, optimization can be done using Stan’s optimizers -


numerical integration? not quite sure what you mean - Stan has a 1D integrator function, which has been discussed in other threads here -

It depends on what kind of numerical integration I suppose. In some sense that’s the main purpose of Stan (MCMC is numerical integration).