def _get_fit(self, time: int) -> typing.Tuple[np.ndarray, np.ndarray, float, float]:
        """
        Fit regression model to data

        :param: time (column of data)

        :return: predicted points
        :return: residuals
        :return: mean residual
        :return: error
        """
        rawdata = self.averagedata[:, time]
        domain = np.arange(len(rawdata))
        datalength = len(domain)
        coefficients = np.zeros((datalength, self.function_number + 2))
        coefficients[:, 0] = 1
        coefficients[:, 1] = domain
        for i in range(self.function_number):
            coefficients[:, 2 + i] = self._gaussian_function(datalength, domain, 1, i)
        betas = linalg.inv(coefficients.transpose().dot(coefficients)).dot(coefficients.transpose().dot(rawdata))
        predicted_values = coefficients.dot(betas)
        residuals = rawdata - predicted_values
        error = np.sqrt(residuals.transpose().dot(residuals) / (datalength - (self.function_number + 2)))
        return predicted_values, residuals, residuals.mean(), error
def _get_fit ( self , time : int ) -> typing . Tuple [ np . ndarray , np . ndarray , float , float ] : rawdata = self . averagedata [ : , time ] domain = np . arange ( len ( rawdata ) ) datalength = len ( domain ) coefficients = np . zeros ( ( datalength , self . function_number + 2 ) ) coefficients [ : , 0 ] = 1 coefficients [ : , 1 ] = domain for i in range ( self . function_number ) : coefficients [ : , 2 + i ] = self . _gaussian_function ( datalength , domain , 1 , i ) betas = linalg . inv ( coefficients . transpose ( ) . dot ( coefficients ) ) . dot ( coefficients . transpose ( ) . dot ( rawdata ) ) predicted_values = coefficients . dot ( betas ) residuals = rawdata - predicted_values error = np . sqrt ( residuals . transpose ( ) . dot ( residuals ) / ( datalength - ( self . function_number + 2 ) ) ) return predicted_values , residuals , residuals . mean ( ) , error
Fit regression model to data

        :param: time (column of data)

        :return: predicted points
        :return: residuals
        :return: mean residual
        :return: error