Stan Math Library
5.0.0
Automatic Differentiation
|
Return the floor of the specified variable (cmath).
The derivative of the floor function is defined and zero everywhere but at integers, so we set these derivatives to zero for convenience,
\(\frac{d}{dx} {\lfloor x \rfloor} = 0\).
The floor function rounds down. For double values, this is the largest integral value that is not greater than the specified value. Although this function is not differentiable because it is discontinuous at integral values, its gradient is returned as zero everywhere.
\[ \mbox{floor}(x) = \begin{cases} \lfloor x \rfloor & \mbox{if } -\infty\leq x \leq \infty \\[6pt] \textrm{NaN} & \mbox{if } x = \textrm{NaN} \end{cases} \]
\[ \frac{\partial\, \mbox{floor}(x)}{\partial x} = \begin{cases} 0 & \mbox{if } -\infty\leq x\leq \infty \\[6pt] \textrm{NaN} & \mbox{if } x = \textrm{NaN} \end{cases} \]
a | Input variable. |