(self, X, U)
return self.Fm, self.fv, self.dyn_covar
Fit dynamics.
Fit dynamics.
Fit dynamics .
def fit(self, X, U):
        """ Fit dynamics. """
        N, T, dX = X.shape
        dU = U.shape[2]

        if N == 1:
            raise ValueError("Cannot fit dynamics on 1 sample")

        self.Fm = np.zeros([T, dX, dX+dU])
        self.fv = np.zeros([T, dX])
        self.dyn_covar = np.zeros([T, dX, dX])

        it = slice(dX+dU)
        ip = slice(dX+dU, dX+dU+dX)
        # Fit dynamics with least squares regression.
        dwts = (1.0 / N) * np.ones(N)
        for t in range(T - 1):
            Ys = np.c_[X[:, t, :], U[:, t, :], X[:, t+1, :]]
            # Obtain Normal-inverse-Wishart prior.
            mu0, Phi, mm, n0 = self.prior.eval(dX, dU, Ys)
            sig_reg = np.zeros((dX+dU+dX, dX+dU+dX))
            sig_reg[it, it] = self._hyperparams['regularization']
            Fm, fv, dyn_covar = gauss_fit_joint_prior(Ys,
                        mu0, Phi, mm, n0, dwts, dX+dU, dX, sig_reg)
            self.Fm[t, :, :] = Fm
            self.fv[t, :] = fv
            self.dyn_covar[t, :, :] = dyn_covar
        return self.Fm, self.fv, self.dyn_covar
def fit ( self , X , U ) : N , T , dX = X . shape dU = U . shape [ 2 ] if N == 1 : raise ValueError ( "Cannot fit dynamics on 1 sample" ) self . Fm = np . zeros ( [ T , dX , dX + dU ] ) self . fv = np . zeros ( [ T , dX ] ) self . dyn_covar = np . zeros ( [ T , dX , dX ] ) it = slice ( dX + dU ) ip = slice ( dX + dU , dX + dU + dX ) # Fit dynamics with least squares regression. dwts = ( 1.0 / N ) * np . ones ( N ) for t in range ( T - 1 ) : Ys = np . c_ [ X [ : , t , : ] , U [ : , t , : ] , X [ : , t + 1 , : ] ] # Obtain Normal-inverse-Wishart prior. mu0 , Phi , mm , n0 = self . prior . eval ( dX , dU , Ys ) sig_reg = np . zeros ( ( dX + dU + dX , dX + dU + dX ) ) sig_reg [ it , it ] = self . _hyperparams [ 'regularization' ] Fm , fv , dyn_covar = gauss_fit_joint_prior ( Ys , mu0 , Phi , mm , n0 , dwts , dX + dU , dX , sig_reg ) self . Fm [ t , : , : ] = Fm self . fv [ t , : ] = fv self . dyn_covar [ t , : , : ] = dyn_covar return self . Fm , self . fv , self . dyn_covar