I’m trying to learn my way around the Stan source so I can try to contribute. I wanted to get a basic idea of which part of the source gets called and in what order, and which subroutines call each other. Is there a diagram that shows this? I couldn’t find anything on the Wiki.

If not, I can always go through it manually. Maybe I can even make a diagram and share it if that would be helpful.

Sure—more doc’s always helpful. We tend to skimp on the dev doc, so that could use some TLC.

A Stan program produces a C++ class (see the model concept doc for details on what this class does). This then gets passed into the service methods already instantiated with data. It’s basically a log density function with transforms and transformed/generated quantities. The Stan functions get translated directly to math library (and std library) functions.

The service methods then call one of the services (sampling, optimization, vi) and use the algorithms there. These algorithms are all templated on the model class. They use the high-level functionals (like gradient) to compute gradients and values of the log density function as used in our algorithms (all of which are gradient based).

The optimiztion code is simplest and the MCMC code is the best organized.