Minimum Energy Estimation of Nonlinear Dynamical Systems in Continuous and Discrete Time