This is an old version, view current version.

18.8 Summary of Function Types

Functions may have a void or non-void return type and they may or may not have one of the special suffixes, _lpdf, _lpmf, _lp, or _rng.

Void vs. Non-Void Return

Only functions declared to return void may be used as statements. These are also the only functions that use return statements with no arguments.

Only functions declared to return non-void values may be used as expressions. These functions require return statements with arguments of a type that matches the declared return type.

Suffixed or Non-Suffixed

Only functions ending in _lpmf or _lpdf and with return type real may be used as probability functions in sampling statements.

Only functions ending in _lp may access the log probability accumulator through sampling statements or target += statements. Such functions may only be used in the transformed parameters or model blocks.

Only functions ending in _rng may access the built-in pseudo-random number generators. Such functions may only be used in the generated quantities block or transformed data block, or in the bodies of other user-defined functions ending in _rng.