hotelling's T2 tests for time domain waveforms

def _hotellings_time(self):
        """ hotelling's T2 tests for time domain waveforms"""
        # get residuals
        df = self._df
        R = self._A - np.dot(self._X, self._Bhat)
        Sigma_Z = np.dot(R.T,R)*(1./df)
        # compute p-values
        T_2_list = []
        p_value_list = []
        for i in np.arange(0,self._Bhat.shape[0]):
            Bstar       = self._Bhat[i,np.arange(0,np.shape(self._A)[1])]
            lstar       = float(np.shape(Bstar)[0])
            cx          = self._Cx[i,i]
            Einv        = np.linalg.pinv(Sigma_Z)
            Zs          = Bstar/np.sqrt(cx)
            T_2         = ((df - lstar + 1.)/(df*lstar)*np.dot(np.dot(Zs,Einv),Zs.T))
            p_value     = 1. - stats.f.cdf(T_2, lstar, df - lstar + 1.)

            p_value_list.append(p_value)
            T_2_list.append(T_2)
        # save pvalue results in a table
        self._results = [['Comparison','Hotellings T^2', "p-value"]]
        for i in np.arange(0,len(self._col_names)):
            self._results.append([self._col_names[i], T_2_list[i], p_value_list[i]])