Skip to content

Instantly share code, notes, and snippets.

@rok-cesnovar
Last active June 21, 2022 12:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rok-cesnovar/3a1419b665f4b09c26f2e56995938c81 to your computer and use it in GitHub Desktop.
Save rok-cesnovar/3a1419b665f4b09c26f2e56995938c81 to your computer and use it in GitHub Desktop.
I am happy to announce that the latest release candidates of Cmdstan and Stan are now available on Github!
This release cycle brings complex vectors and matrices, 6 new functions and 3 new distributions.
You can find the release candidate for cmdstan [here](). Instructions for installing are given at the bottom of this post.
Please test the release candidate with your models and report if you experience any problems. We also kindly invite you to test the new features and provide feedback. If you feel some of the new features could be improved or should be changed before the release, please do not hesitate to comment.
The Stan development team appreciates your time and help in making Stan more efficient while maintaining a high level of reliability.
If everything goes according to plan, the 2.30 version will be released in about ten days.
Below are some of the highlights of the new release.
## 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,
- columns_dot_self,
- cumulative_sum,
- diag_matrix,
- diagonal,
- dot_self,
- eigenvalues_sym,
- eigenvectors_sym,
- fft,
- fft2,
- inv_fft,
- inv_ftt2,
- prod,
- reverse,
- rows_dot_self,
- singular_values,
- sum,
- svd_U,
- svd_V,
- symmetrize_from_lower_tri,
- transpose,
- trace
Other utility functions:
- get_imag, get_real,
- cols, rows, num_elements, size,
- to_array_1d, to_matrix, to_row_vector, to_vector
`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 FFT functions are temporarily available [here](https://github.com/stan-dev/docs/blob/1961f88828e406ff31a85dff699b67f686efd7dc/src/functions-reference/complex_matrix_operations.Rmd#L1179). The rest of the listed functions are all existing functions that were extended to support the new complex types.
In addition to these, two new functions were added that return complex vectors/matrices: `eigenvectors` and `eigenvalues`. See the next section for details.
Note that real vectors/matrices automatically promote to complex vector/matrices, which means that supplying a vector to `fft(complex_vector)` will work seamlessly, no need to wrap the vector in a `to_complex()`.
# New functions
- `eigenvectors` and `eigenvalues`:
`eigenvalues` returns the complex-valued vector of eigenvalues of the 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`.
[Temporary documentation link.](https://github.com/stan-dev/docs/blob/1961f88828e406ff31a85dff699b67f686efd7dc/src/functions-reference/matrix_operations.Rmd#L2208)
- `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)`.
[Temporary documentation link.](https://github.com/stan-dev/docs/blob/c03dd568616d5fcbd7978d6832dfb7712f374ced/src/functions-reference/real-valued_basic_functions.Rmd#L1181)
- `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.
[Temporary documentation link.](https://github.com/stan-dev/docs/blob/1961f88828e406ff31a85dff699b67f686efd7dc/src/functions-reference/matrix_operations.Rmd#L2123)
- `norm1`, `norm2`
These functions return the L1 and L2 norms.
[Temporary documentation link.](https://github.com/stan-dev/docs/blob/c03dd568616d5fcbd7978d6832dfb7712f374ced/src/functions-reference/real-valued_basic_functions.Rmd#L1181)
## New distributions
- Multivariate Student-t distribution, Cholesky parameterization: `multi_student_t_cholesky_lpdf` and `multi_student_t_cholesky_rng`
[Temporary documentation link.](https://github.com/stan-dev/docs/blob/e46d7abd8729c0ace3c2112ee785a99cc3007218/src/functions-reference/distributions_over_unbounded_vectors.Rmd#L597)
- Wishart distribution, Cholesky Parameterization: `wishart_cholesky_lpdf` and `wishart_cholesky_rng`
[Temporary documentation link.](https://github.com/stan-dev/docs/blob/ff8fca509e6a7fe807826a7fc5b4ffed68ee2ded/src/functions-reference/covariance_matrix_distributions.Rmd#L69)
- Inverse Wishart distribution, Cholesky Parameterization: `inv_wishart_cholesky_lpdf` and `inv_wishart_cholesky_rng`
[Temporary documentation link.](https://github.com/stan-dev/docs/blob/ff8fca509e6a7fe807826a7fc5b4ffed68ee2ded/src/functions-reference/covariance_matrix_distributions.Rmd#L183)
## 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 can not be used with 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.
Toolchain support on Mac and Linux systems should remain unchanged.
## Miscellenous
- Downstream libraries were updated: Sundials to 6.1.1 and Boost to 1.78.0
- `./` anb `.*`, 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.
## 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 have an online Cmdstan guide available at https://mc-stan.org/docs/2_28/cmdstan-guide/
If you are using cmdstanpy you can install the release candidate using
```
cmdstanpy.install_cmdstan(version='2.30.0-rc1')
```
With CmdStanR you can install the release candidate using
```r
cmdstanr::install_cmdstan(version = "2.30.0-rc1", cores = 4)
```
And then select the RC with
```r
cmdstanr::set_cmdstan_path(file.path(Sys.getenv("HOME"), ".cmdstanr", "cmdstan-2.30.0-rc1"))
```
@rok-cesnovar
Copy link
Author

Thanks, fixed the multiply/divide text!

Added this:

Note that real vectors and matrices automatically promote to 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()`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment