Defining a proper disturbance value
We have hard-coded a disturbance value (1e-5) for each piece of code that applies numerical differentiation. You can see this in the following classes:
ActionModelNumDiff
CostModelNumDiff
DifferentialActionModelNumDiff
Despite this value produces reasonable good estimation of the derivatives is not the most effective value. Let me explain here with a little of math. The numerical differentiation error is bounded as:
\frac{\delta}{h}|f(x)| + \frac{h}{2}|f''(x)| + O(h^2)
where \delta
and h
represent the epsilon machine and disturbance, respectively.
For instance if we assume f(x)=\sin(x)
the minimum of this error is found at \frac{\delta}{h}+\frac{h}{2}
, which gives us the follows: h = \sqrt{2\delta}=\approx 2\cdot 10^{-8}
.
In the literature, as a general rule, it uses h = \sqrt{2\delta}=\approx \cdot 10^{-8}
as well.