I am happy to announce that the latest release candidates of Cmdstan and Stan are now available on Github!

This release cycle brings new ODE solvers, new language/syntax improvements, new functions, performance improvements and bugfixes.

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.27 version will be released next Thursday.

Below are some of the highlights of the new release.

### Adjoint ODE

We added a new adjoint ODE solver from CVODES. The adjoint ODE method has favourable performance scaling for large ODE problems with many more parameters than ODE states. As the adjoint ODE approach is numerically more involved, we are exposing the feature for more advanced users such that most tuning parameters of the solver are being exposed. We intend to provide a simplified adjoint ODE solver interface once the community has collected more experience with the solver. For more details for now refer to the design document: design-docs/0027-adjoint-ode.md at master · stan-dev/design-docs · GitHub

More documentation will be available once we officially release.

### A new ODE solver - Cash-Karp

We also added another new solver that solves the ODE system using the Cash-Karp algorithm, a 4th/5th order explicit Runge-Kutta method. The Cash-Karp algorithm should improve numerical integration of ODEs with semi-stiffness and/or rapid oscillations.

### New array syntax

We silently added support for a new array syntax in the previous release. With this release this new syntax is becoming more prominent and will be used in error messages, documentation and example models. As opposed to the previously used syntax for arrays:

```
real a[5];
matrix[3,3] b[5];
vector[3] c[5];
```

we recommend switching to the new equivalent array syntax:

```
array[5] real a;
array[5] matrix[3,3] b;
array[5] vector[3] c;
```

The old syntax will be supported for the forseable future but we strongly encourage getting used to the new syntax.

### Multiple definitions in one declaration statements

We have added support to allow declaring and defining more than one variable with the same declaration statement, given that they have the same type.

So the following will now be valid in Stan 2.27+:

```
data {
real x, y, z;
array[5] int i, j;
}
transformed data {
real a = 5, b = 6;
real c = 5, d, e = 7;
}
```

### New functions and signatures

We added a new function to compute the quantiles in the transformed data or generated quanties. The following signatures are supported:

```
quantile(data vector, data real) => real
quantile(data row_vector, data real) => real
quantile(data array[] real, data real) => real
quantile(data vector, data array[] real) => array[] real
quantile(data row_vector, data array[] real) => array[] real
quantile(data array[] real, data array[] real) => array[] real
```

The `fma()`

function now supports more vectorized signatures:

```
fma(real, real, vector) => vector
fma(real, vector, real) => vector
fma(real, vector, vector) => vector
fma(vector, real, real) => vector
fma(vector, real, vector) => vector
fma(vector, vector, real) => vector
fma(vector, vector, vector) => vector
```

and for `row_vector`

and `matrix`

arguments instead of `vector`

.

### Performance optimizations

The following functions should have improved performance:

- diag_pre_multiply
- diag_post_multiply
- multi_normal_cholesky (when covariance is data)
- csr_matrix_times_vector (for cases when the matrix is data and the vector is a parameter)

We also improved handling data and transformed data by avoiding an unecessary copy when using reverse mode.

### Improved range checks

We have improved the range checks when accesing elements of a vector/row_vector/matrix or array.

These will now return a more informative error in case of a users bug with indexing like setting an index out of a vector’s range.

These checks can in some cases add a noticeable performance regression of around 10%. Users can use the

STAN_NO_RANGE_CHECKS make flag to avoid the range checks in favor of maximum performance.

We advise only turning the checks off once you are sure in the correctness of indexing in your model.

### Miscellaneous improvements:

- More robust detection of improper posteriors.
- Standalone generated quantities will also run on warmup draws if supplied.
- The
`fixed_param`

method is run automatically if the model has no parameters. - The
`_cdf`

functions now also use the vertical bar (`|`

) form, matching the lcdf/lcdf/lpdf/lpmf functions. - Fixed an issue with a memory leak with the OpenCL backend.
- The Stan-to-C++ compiler can now output lists of data, parameter and GQ variables in JSON form.
- Avoiding copying data/transformed data in the stack allocator when doing reverse mode.

### Updated downstream dependencies

The TBB library has been upgraded to the 2020.3 version and the Sundials library has been updated to 5.7.0.

## 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 CmdStan User’s Guide

If you are using cmdstanpy, make sure you point to the folder where you extracted the tar.gz file with

```
set_cmdstan_path(os.path.join('path','to','cmdstan'))
```

With CmdStanR you can install the release candidate using

```
cmdstanr::install_cmdstan(version = "2.27.0-rc1", cores = 4)
```

And then select the RC with

```
cmdstanr::set_cmdstan_path(file.path(Sys.getenv("HOME"), ".cmdstanr", "cmdstan-2.27.0-rc1"))
```