We are very happy to announce that the next release of Cmdstan (2.24.1) is now available on Github.
You can find it here: https://github.com/stan-dev/cmdstan/releases/tag/v2.24.1 2
- A new ODE interface
- Functions for hidden Markov models with a discrete latent variable
- Elementwise pow operator and matrix power function
- Newton solver
- Support for the multinomial logit distribution
- Reverse function
- Integer division operator
- Pedantic mode
- Non-scalar values in lower, upper, offset and multiplier
- Faster compile times and easier handling of threading
- A new and improved stansummary
This is amazing. All this in a version 2.24.1! Also, Stan is fully open source, and we encourage developers of other probabilistic programming languages to implement any and all of these features in their systems as well.
We thank our funders as well as all the many people who put in volunteer effort on this project.
Here are the details of the new features:
There were ~150 pull requests merged for this release, code was contributed by 17 developers:
@Adam_Haber , @andrjohns, @bbbales2, @Bob_Carpenter, @charlesm93, Christopher22 , @simon, HaoZeke, @IvanYashchuk , @mitzimorris , @nhuurre, @peterwicksstringfield, @rybern, @serban-nicusor, @SteveBronder, @tadej and @rok_cesnovar.
Also huge thanks to everyone that contributed with code reviews!
How to install?
Download the tar.gz file from the link above, extract it and use it the way you use any Cmdstan release. We also now have an online Cmdstan guide available at https://mc-stan.org/docs/2_24/cmdstan-guide/
With cmdstanpy you can update to the new release using:
import cmdstanpy cmdstanpy.install_cmdstan()
With cmdstanr you can update to the new release using:
library(cmdstanr) install_cmdstan()New features
This release comes with a lot of new features and bugfixes. The detailed release notes for Cmdstan and all the submodules can be found here. If you have any questions or cannot find the documentation, do not hesitate to ask. Below are some of the highlights.
A new ODE interface
The new ODE interface is intended to make it easier to specify the ODE RHS by avoiding packing and unpacking schemes required with the old interface. It is important to switch to the new interfaces because the old interfaces are significantly slower than they were previously (we have seen up to 30%)
The new functions are:
vector ode_bdf(F f, vector y0, real t0, real times, ...) vector ode_adams(F f, vector y0, real t0, real times, ...) vector ode_rk45(F f, vector y0, real t0, real times, ...) vector ode_bdf_tol(F f, vector y0, real t0, real times, real rel_tol, real abs_tol, int max_num_steps, ...) vector ode_adams_tol(F f, vector y0, real t0, real times, real rel_tol, real abs_tol, int max_num_steps, ...) vector ode_rk45_tol(F f, vector y0, real t0, real times, real rel_tol, real abs_tol, int max_num_steps, ...)
...can be argument(s) of any type.
For examples converting ODEs written with the old interface to the new interface, look at the case study Upgrading to the new ODE interface.
Functions for Hidden Markov Models with a discrete latent variable
matrix hmm_hidden_state_prob(matrix, matrix, vector) int hmm_latent_rng(matrix, matrix, vector) real hmm_marginal(matrix, matrix, vector)
For detailed information, check out the Hidden Markov Models 1 section in the Function Reference.
Elementwise pow operator and matrix power function
The .^ operator now supports elementwise pow. The following examples are now all supported:
vector .^ vector row_vector .^ row_vector matrix .^ matrix int .^ matrix matrix .^ int matrix .^ real vector .^ real vector .^ vector int .^ matrix row_vector .^ real row_vector .^ real ...
A new matrix matrix_power is also available with the signature:
matrix matrix_power(matrix, int)
For detailed information, check out the Matrix Power section in the Functions Reference.
The Newton solver is available via
vector algebra_solver_newton((vector, vector, data real, data int) => vector, vector, vector, real, int) vector algebra_solver_newton((vector, vector, data real, data int) => vector, vector, vector, real, int, real, real, real)
For detailed information, check out the Algebraic Equation Solver section in the Functions Reference.
Support for the multinomial logit distribution
real multinomial_logit_log(int, vector) real multinomial_logit_lpmf(int, vector) int multinomial_logit_rng(vector, int)
For detailed information, check out the Multivariate Discrete Distributions 1 section in the Functions Reference.
T is vector, row_vector or an array of any type
For detailed information, check out the Reverse Functions section in the Functions Reference.
Integer division operator
A new integer division operator was added:
%/%. Dividing integer numbers with the
/operator will warn.
You can now run a pedantic check on your model that warns you about potential issues in your Stan program.
You can enable it in Cmdstan by adding a
--warn-pedanticflag to STANCFLAGS.
You can enable it in cmdstanr with the
model = cmdstan_model("test.stan", stanc_options = list("warn-pedantic" = TRUE))
For detailed information, check out the Pedantic mode section in the Reference Manual.
Non-scalar values in lower, upper, offset and multiplier
Non-scalar values are now allowed in lower, upper, offset and multiplier transforms if the value has the same type and size as the declared variable.
real L[K]; real U[K]; vector<lower = L, upper = U>[K] alpha;
Faster compile times and easier handling of threading
If you are using the
g++C++ compiler, the Stan models should now compile ~50% faster. If you are using the
clangC++ compiler, the models should compile ~20% faster than with Cmdstan 2.23.
On Linux and macOS this speedup is available out of the box. On Windows, if you are using the toolchain available with RTools 4.0, you have to add
make/localfile. This speedup is unfortunately not available with RTools 3.5 on Windows.
A new and improved stansummary
Added option of returning custom quantiles
Separate summaries for sampler and model params
A lot of minor improvements for stability and maintainability