Which function is faster?


#1

Hi all,

I have a parameter kappa, a number t. In the model block I need the following expression

exp(kappa * t)

The are two ways:
(1) define kappa as a parameter, and use that expression, or
(2) define new_kappa = exp(kappa) and use

new_kappa^t.

Which do you think being faster?

Thank you for reading!

Kind regards,
Trung Dung.


#2

The first way is at least as fast and more clear because Stan has to calculate log(new_kappa) to do the autodiff.


#3

I would suggest testing. It’s more precise than speculating.