What is Stan (mc-stan.org)?
Updated
Stan is an open-source software platform for Bayesian data analysis. It provides a probabilistic programming language for building statistical models and performing Bayesian inference, with interfaces for Python, Julia, R, and the Unix shell. It is the right tool to look at if you want to fit Bayesian models — from simple linear regression to multi-level and time-series models — and prefer to write the model declaratively rather than hand-code a sampler.
What Stan actually does
Stan separates the model from the computation. You write a model in the Stan language, and Stan handles the inference. The site describes this as combining "powerful statistical modeling capabilities with user-friendly interfaces."
The core pieces:
- A probabilistic programming language. You declare data, parameters, and a model; Stan compiles it and runs the inference.
- Bayesian inference. The site frames the goal as "more accurate and interpretable results in complex data scenarios."
- Flexible and scalable. The same language covers simple linear regression through multi-level models and time-series analysis, and runs on laptops, clusters, or in the cloud.
- A toolkit around the model. Validation and visualization tools support "decision-making and communication."
A concrete example
The site's own example is a Bernoulli model — estimating a probability theta from binary outcomes:
data {
int<lower=0> N;
array[N] int<lower=0, upper=1> y;
}
parameters {
real<lower=0, upper=1> theta;
}
model {
// uniform prior on interval 0,1
theta ~ beta(1, 1);
y ~ bernoulli(theta);
}
Read it as three blocks: data is what you supply, parameters is what Stan estimates, and model states the prior and the likelihood. You don't write a sampler — declaring y ~ bernoulli(theta) is enough for Stan to infer the posterior for theta.
Interfaces and where it runs
| Interface | Use it when |
|---|---|
| Python | You work in a Python analysis stack |
| R | You work in R |
| Julia | You work in Julia |
| Unix shell | You want to run models from the command line |
The same models run across these environments, on laptops, clusters, or in the cloud — so you can prototype locally and scale up without rewriting the model.
Learning resources on the site
- Getting Started and Documentation — installation and language reference.
- Tutorials and Case Studies — worked examples you can adapt to your own projects.
- Learning Resources and Domain-specific Publications — material organized by field.
- Diagnostics and Warnings — how to tell when a fit has gone wrong.
- StanCon Talks — conference presentations.
- Prior Choice Recommendations wiki — guidance on choosing priors for use with Stan.
Community and developer support
The Stan forums cover "all user levels and topics, from installing software, to writing Stan programs, to advanced Bayesian modeling techniques and methodology." For development work there is the Stan Developer Wiki, a Developers category on the forums, and the Slack channel at mc-stan.slack.com for informal developer discussion.
When Stan is a good fit
Choose Stan when your problem is genuinely Bayesian, when you need a model that doesn't fit a standard canned procedure (multi-level structure, custom likelihoods, time series), or when you want the same model to run from R, Python, Julia, or the shell. If you only need a quick frequentist regression with no custom structure, a lighter library in your existing language may get you there faster — Stan's value shows up when the model itself is the hard part.