Release of CmdStan 2.28.1

We are very happy to announce that the 2.28.1 release of CmdStan is now available on Github! As usual, the release of CmdStan 2.28.1 is accompanied with the new releases of Stan Mathcore Stan and Stanc3.

There was a release of 2.28.0 a few days ago, but we quickly identified a few bugs that were since squashed and this post highlights the work done for both the 2.28.0 and 2.28.1 release.

This new release brings a new a new complex type, a new built-in distribution, faster algebra solvers, faster inv_Phi function, improved sampling with multiple chains and better error messaging.

Install instructions are provided at the end of the post.


We would like to thank everyone that contributed to this release with their bug reports, feature or bug fix discussions, code or code reviews!

In total, we had code and docs contributions from 23 developers and users in this release cycle, including 10 first time contributors. We would also like to welcome four new Stan developers that accepted the invitation to formally join our Stan development team: Brian Ward, Johann Gaebler, Nick DiDio and Yuling Yao.

Brian is working all across the project, most prominently in the stanc3 and CmdStanPy repositories. Brian’s latest contributions include work on the new complex type and various minor fixes to improve the stability of our Stan-to-C++ compiler and the CmdStanPy wrapper.

Johann was working on improving the performance of our algebra solvers. This feature is one of the highlights of this release.

Nick has been helping Brian and Bob Carpenter on adding support for the new complex type across all of our submodules.

Yuling has been contributing to the Stan project for awhile, making contributions to the loo package, ADVI diagnostics and in many of the corners of our project.

Please join us in welcoming them to the project. Thank you to each and everyone for your contributions!

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.

You can support Stan via NumFocus or the Github sponsorship program.

Release highlights

Complex type

Stan now supports complex numbers with all of the standard complex functions, including natural logarithm log(z), natural exponentiation exp(z), and powers pow(z1, z2), as well as all of the trig and hyperbolic trigonometric functions and their inverse, such as sin(z)acos(z)tanh(z) and asinh(z).

Detailed documentation can be found in the Users’ guide section on complex number here.

Skew double exponential distribution

All typical distributions-related functions are now available for the Skew double exponential distribution:


The functions reference is available here.

More efficient multi-chain sampling with Cmdstan using threads in a single executable

It is now possible to sample with NUTS using multiple chains within a single executable. The multiple chains run in parallel using TBB threads. This should be slightly faster in general and also reduce the memory footprint as all chains share the same copy of the input data, while previously each chain had its own copy of all the input data.

When using within-chain parallelization all chains started within a single executable can share all the available threads. This means what once a chain finishes the threads will be reused in the other chains. This type of resource sharing was previously unavailable.

More details are available here.

New num_threads command-line argument

The number of threads used with within-chain parallelization can now be specified as a command line argument to the CmdStan executable.

Previously the number of threads was specifed via an environment variable STAN_NUM_THREADS.

Details are available here.

More efficient Power & Newton algebra solvers and the inv_Phi function

The auto differentiation for the Powell and Newton solvers now more efficiently compute cotangents by replacing matrix inversion with a smaller number of matrix solves.

The inv_Phi should also approximately twice as fast with precision of 16 digits with changes based on the Fortran algorithm described in Wichura, M. J. (1988) Algorithm AS 241: The percentage points of the normal distribution. Applied Statistics, 37, 477–484.

Automatic handling of precompiled headers on Windows with RTools 4.0

With CmdStan 2.28, precompiled headers, which are used to speedup model compilation, are enabled by default on Windows when using the C++ toolchain included with RTools 4.0. Previously, they were only enabled if the user manually specified PRECOMPILED_HEADERS=true in the make/local file.

Improved error messaging/type error explanations in stanc3

The Stan-to-C++ compiler has gotten a revamp of the error messaging, particularly with better explanations in case of type mismatches.

How to install the new release?

Download the tar.gz file from the CmdStan release page, extract it and use it the way you use any Cmdstan release. We also have an online Cmdstan guide available for new users.

If you are using cmdstanpy install the new release using

import cmdstanpy

With CmdStanR you can install the new release using

install_cmdstan(cores = 4)

The next release is planned for end of January.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s