Stan Math Library
4.9.0
Automatic Differentiation
|
Returns the rounded form of the specified variable (C99).
The derivative is zero everywhere but numbers half way between whole numbers, so for convenience the derivative is defined to be everywhere zero,
\(\frac{d}{dx} \mbox{round}(x) = 0\).
\[ \mbox{round}(x) = \begin{cases} \lceil x \rceil & \mbox{if } x-\lfloor x\rfloor \geq 0.5 \\ \lfloor x \rfloor & \mbox{if } x-\lfloor x\rfloor < 0.5 \\[6pt] \textrm{NaN} & \mbox{if } x = \textrm{NaN} \end{cases} \]
\[ \frac{\partial\, \mbox{round}(x)}{\partial x} = \begin{cases} 0 & \mbox{if } -\infty\leq x\leq \infty \\[6pt] \textrm{NaN} & \mbox{if } x = \textrm{NaN} \end{cases} \]
a | Specified variable. |