def update(self, z, R=None, hx_args=()):
        """ Update the CKF with the given measurements. On return,
        self.x and self.P contain the new mean and covariance of the filter.

        Parameters
        ----------

        z : numpy.array of shape (dim_z)
            measurement vector

        R : numpy.array((dim_z, dim_z)), optional
            Measurement noise. If provided, overrides self.R for
            this function call.

        hx_args : tuple, optional, default (,)
            arguments to be passed into Hx function after the required state
            variable.
        """

        if z is None:
            self.z = np.array([[None]*self.dim_z]).T
            self.x_post = self.x.copy()
            self.P_post = self.P.copy()
            return

        if not isinstance(hx_args, tuple):
            hx_args = (hx_args,)

        if R is None:
            R = self.R
        elif isscalar(R):
            R = eye(self.dim_z) * R

        for k in range(self._num_sigmas):
            self.sigmas_h[k] = self.hx(self.sigmas_f[k], *hx_args)

        # mean and covariance of prediction passed through unscented transform
        zp, self.S = ckf_transform(self.sigmas_h, R)
        self.SI = inv(self.S)

        # compute cross variance of the state and the measurements
        m = self._num_sigmas  # literaure uses m for scaling factor
        xf = self.x.flatten()
        zpf = zp.flatten()
        Pxz = outer_product_sum(self.sigmas_f - xf, self.sigmas_h - zpf) / m

        self.K = dot(Pxz, self.SI)        # Kalman gain
        self.y = self.residual_z(z, zp)   # residual

        self.x = self.x + dot(self.K, self.y)
        self.P = self.P - dot(self.K, self.S).dot(self.K.T)

        # save measurement and posterior state
        self.z = deepcopy(z)
        self.x_post = self.x.copy()
        self.P_post = self.P.copy()

        # set to None to force recompute
        self._log_likelihood = None
        self._likelihood = None
        self._mahalanobis = None
def update ( self , z , R = None , hx_args = ( ) ) : if z is None : self . z = np . array ( [ [ None ] * self . dim_z ] ) . T self . x_post = self . x . copy ( ) self . P_post = self . P . copy ( ) return if not isinstance ( hx_args , tuple ) : hx_args = ( hx_args , ) if R is None : R = self . R elif isscalar ( R ) : R = eye ( self . dim_z ) * R for k in range ( self . _num_sigmas ) : self . sigmas_h [ k ] = self . hx ( self . sigmas_f [ k ] , * hx_args ) zp , self . S = ckf_transform ( self . sigmas_h , R ) self . SI = inv ( self . S ) m = self . _num_sigmas xf = self . x . flatten ( ) zpf = zp . flatten ( ) Pxz = outer_product_sum ( self . sigmas_f - xf , self . sigmas_h - zpf ) / m self . K = dot ( Pxz , self . SI ) self . y = self . residual_z ( z , zp ) self . x = self . x + dot ( self . K , self . y ) self . P = self . P - dot ( self . K , self . S ) . dot ( self . K . T ) self . z = deepcopy ( z ) self . x_post = self . x . copy ( ) self . P_post = self . P . copy ( ) self . _log_likelihood = None self . _likelihood = None self . _mahalanobis = None
Update the CKF with the given measurements. On return,
        self.x and self.P contain the new mean and covariance of the filter.

        Parameters
        ----------

        z : numpy.array of shape (dim_z)
            measurement vector

        R : numpy.array((dim_z, dim_z)), optional
            Measurement noise. If provided, overrides self.R for
            this function call.

        hx_args : tuple, optional, default (,)
            arguments to be passed into Hx function after the required state
            variable.