We are very happy to announce that the 2.40.0 release of CmdStan is now available on Github! As usual, the release of CmdStan is accompanied by new releases of Stan Math, core Stan, and Stanc3.
This release cycle brings new 1-D integration functions, quality of life improvements, and many bug fixes.
Contributors, sponsors and donators
We would like to thank everyone that contributed to this release with their bug reports, feature or bug fix discussions, and code or code reviews. We’d like to especially shout out to those contributors who attended the workshops we held at StanCon 2026 Uppsala and made their first contributions during this release cycle!
We would also like to thank all of our sponsors and donators who have supported us during this last release cycle and in years past. Thanks to the Flatiron Institute for providing us with the computing resources to run unit tests and build scripts for our repositories.
You can support Stan via NumFocus or the Github sponsorship program.
Release highlights
New options for 1d integration
Several new integration functions have been added:
integrate_1d_double_exponential, a variadic version of the existing 1-d integratorintegrate_1d_gauss_kronrod, a variadic function with a different quadrature rule
Documentation can be found here.
Matrix reshaping functions
New functions to_vector_array(matrix) -> array[] vector to_row_vector_array(matrix) -> array[] row_vector, as well as new overloads for to_matrix for arrays of (row-)vectors.
New poisson_binomial distribution
A new discrete PMF, CDF, CCDF, and RNG functions available.
Documentation is available here.
Other changes
There have been various other bug fixes and usability improvements this release, thank you to everyone who reported a bug in the last few months!
The same .stanfunctions can be #included multiple times without leading to errors about duplicated function definitions.
New functions for getting the mean and covariance estimates out of the embedded Laplace approximation added in 2.39.0
Updated the Math library to use Eigen 5.0.1
The vectorized RNGs were updated to fix a crash when given size-0 inputs.
The compiler has fewer dependencies, with a smaller binary size and improved speeds.
Additional details are available in the release notes for each project:
How to install the new release?
Download the tar.gz file here, extract it, and use it the way you use any CmdStan release. We also have an online CmdStan guide available at https://mc-stan.org/docs/cmdstan-guide.
If you are using cmdstanpy you can install using
cmdstanpy.install_cmdstan()
With CmdStanR you can install using
cmdstanr::install_cmdstan()
Note that both cmdstanpy and CmdStanR users are recommend to update their versions of those libraries when installing a new CmdStan to get support for newer features and the latest bug fixes.
