We are very happy to announce that the 2.30.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 complex vectors, row vectors, and matrices, six new functions and three new distributions, and a number of minor improvements and bugfixes.
Install instructions are provided at the end of the blog post.
Contributors
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!
In total, we had code and docs contributions from 14 developers and users in this release cycle, including a first-time contributor. In this cycle, the developers with the most contributions were Brian Ward, who has been working on complex vectors and matrices as well as a number of improvements in the Stan-to-C++ transpiler, and Sean Pinkney who has been working on the new distributions and functions and improving the performance of existing functions.
Thank you to each of our contributors for your work!
Sponsors and donators
We would like to express a big THANK YOU to all of our sponsors and donators that have been supporting us during this last release cycle and in years past.
We would also like to specifically thank 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
Complex vectors, row_vector, and matrices
The Stan language gains three new types: complex_vector
, complex_row_vector
and complex_matrix
with a number of functions that support them:
- abs,
- cols,
- columns_dot_self,
- cumulative_sum,
- diag_matrix,
- diagonal,
- dot_self,
- eigenvalues_sym,
- eigenvectors_sym,
- get_imag,
- get_real,
- fft,
- fft2,
- inv_fft,
- inv_ftt2,
- num_elements,
- prod,
- reverse,
- rows,
- rows_dot_self,
- singular_values,
- size,
- sum,
- svd_U,
- svd_V,
- symmetrize_from_lower_tri,
- to_array_1d, to_matrix, to_row_vector, to_vector,
- transpose,
- trace
fft()
returns the Fourier transform of a vector, while fft2()
can be used for the 2-dimensional case of the Fast Fourier transform. The inv_fft()
and inv_fft2()
provide the respective inverse transforms. More details on the complex matrix and vector operations are available here.
Brian Ward, Bob Carpenter, and David Barmherzig have also prepared a case study in which they perform image reconstruction in Stan by implementing the HoloML phase retrieval model and then solving the inverse problem with optimization which uses the new Fast Fourier transform functions. The case study is available here.
In addition to the above-listed functions, two new functions were added that return complex vectors/matrices: eigenvectors
and eigenvalues
. See the next section and the functions reference for more.
Note that real vectors/matrices automatically promote complex vector/matrices, which means that supplying a vector to fft(complex_vector)
will work seamlessly, with no need to wrap the vector in a to_complex()
.
New functions
In addition to the Fast Fourier transform functions, this release brings six new functions:
– eigenvectors
and eigenvalues
:
eigenvalues
returns the complex-valued vector of eigenvalues of matrix A. The eigenvalues are repeated according to their algebraic multiplicity, so there are as many eigenvalues
as rows in the matrix. The eigenvalues are not sorted in any particular order. eigenvectors
returns the matrix with the complex-valued (column) eigenvectors of the matrix A in the same order as returned by eigenvalues
.
Functions reference is available here.
– inv_inc_beta
The inverse of the regularized incomplete beta function. The return value x
is the value that solves p = inc_beta(alpha, beta, x)
.
Functions reference is available here.
– log_determinant_spd
The log of the absolute value of the determinant of the symmetric, positive-definite matrix A. This function is faster when the input matrix is known to be symmetric and positive definite.
Functions reference is available here.
– norm1
, norm2
These functions return the L1 and L2 norms.
Functions reference is available here.
New distributions
There are 3 new Cholesky parameterized lupdf/lpdf distributions and their rng functions
– wishart_cholesky
is the Cholesky parameterization of the wishart
distribution
– inv_wishart_cholesky
is the Cholesky parameterization of the inv_wishart
distribution
– multi_student_t_cholesky
is the Cholesky parameterization of the multi_student_t
distribution
Functions reference links: multi_student_t_cholesky, wishart_cholesky, inv_wishart_cholesky.
These will be more stable for large dimensional problems by using the Cholesky factor directly in the parameters block by declaring a cholesky_factor_corr
or cholesky_factor_cov
matrix type. This obviates the need to use a Cholesky decomposition on the positive-definite matrix prior to usage elsewhere.
## Deprecations
The fabs()
function is now deprecated and will be removed in the 2.33.0 release (estimated to be released in June 2023). All usages of fabs()
can be replaced with abs()
.
Discontinued support for Rtools 3.5 on Windows
The Stan 2.30 release and all future versions will no longer support the Rtools 3.5 toolchain on Windows. The recommended toolchain on Windows is Rtools40 unless you are using Stan with R 4.2+, in which
case Rtools42 should be used.
The minimum toolchain requirement on Mac and Linux systems remains unchanged.
Miscellaneous
– Downstream libraries were updated: Sundials to 6.1.1 and Boost to 1.78.0
– ./
and .*
, as well as /
, and *
now support the same input types. The support was not consistent in previous versions.
– Exposed an overload for cumulative_sum
which takes and returns an array of integers.
– A new debug-mem-patterns
flag was added to stanc3 that returns the information on what memory pattern was used for vectors and matrices. This is useful when exploring the `O1` optimization that was added in the previous release cycle.
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()