We are very happy to announce that the 2.31.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. A PyStan update will follow shortly.
This new release brings algebraic solver functions with variadic arguments, truncation syntax for vectorized sampling statements, quantile functions (inverse-CDFs), complex-valued Schur decomposition for matrices and direct access to the log_prob function and the gradients in CmdStan and other minor bugfixes.
Install instructions are provided at the end of the blog post.
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 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 algebraic solver functions with variadic arguments
The algebraic solver functions were refactored to support variadic arguments, making them simpler to use, especially with a larger number of arguments in the algebra system user-defined function. The Stan language gains four new functions: solve_powell
, solve_powell_tol
, solve_newton
and solve_newton_tol
.
See the updated section on algebraic equation solvers here.
Truncation syntax for vectorized sampling statements
This new feature allows statements like shown below.
y ~ normal(mu1, sigma1) T[L, U];
in place of
for (n in 1 : N) {
y[n] ~ normal(mu2, sigma2) T[L, U];
}
Note that L and U are required to be scalars. In previous versions, the truncation syntax was only allowed with non-vectorized sampling statements.
New functions
– quantile functions (inverse-CDFs): std_normal_qf
and std_normal_log_qf
. Documentation link.
– complex-valued Schur decomposition for matrices: complex_schur_decompose_t
() and complex_schur_decompose_u()
. Documentation link.
– to_int(data real)
and to_int(data array[...] real)
functions for real-to-int conversion of data variables.
New CmdStan method for calculating log_prob and its gradients
It is now possible to directly call the log_prob function and obtain the gradients with given unconstrained and constrained parameters, similar to the existing Rstan’s log_prob
and grad_log_prob
functionality. User-facing documentation on how to use this functionality will be added shortly. An example call would be something like:
./bernoulli data file=data.json output file=output.csv method=log_prob constrained_params=params.json
or
./bernoulli data file=data.json output file=output.csv method=log_prob unconstrained_params=params.json
where the examples for constrained and unconstrained parameter JSON files for an example model can be seen here and here. This is intended primarily for diagnostics and is not an efficient way of computing the log probability for tools like new samplers.
Miscellaneous
– Implicit real-to-boolean conversions are now deprecated. Please use comparison operators to explicitly convert to a boolean.
– compile time errors and warnings have been improved and updated for clarity
How to install the new release?
Download the tar.gz file from the link above, 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()