docs icon indicating copy to clipboard operation
docs copied to clipboard

describe how to make sum-to-zero parameters "optional" in User's Guide

Open bob-carpenter opened this issue 3 months ago • 0 comments

I liked this suggestion from @WardBrian and think it should be in the User's Guide, because it's a tricky edge case. The context is sum-to-zero vectors, but if there isn't a section on the optionality-with-arrays trick, we should add a whole section.

Note that the fix will just mean your code will be rejected with a nicer error -- you still won't be able to declare a size-0 `sum_to_zero_vector`, since the number of free parameters for this type is one fewer than the declared size, like a simplex.

To make one 'optional', you can either do array[NB] sum_to_zero_vector[S] or declare it as size-1 when it isn't needed, which will make it have no free parameters under the hood: sum_to_zero_vector[NB ? S : 1]

bob-carpenter avatar Oct 17 '25 15:10 bob-carpenter