def Python_linfit(x_true, y, y_err, errors_output = True): Regression_Fit, Uncertainty_Matrix, Red_Chi_Sq, Residuals = linfit(x_true, y, y_err, cov=True, relsigma=False, chisq=True, residuals=True) m_n_Matrix = [sqrt(Uncertainty_Matrix[t,t]) for t in range(2)] R_Factor = Uncertainty_Matrix[0,1]/(m_n_Matrix[0]*m_n_Matrix[1]) m, m_error = Regression_Fit[0], m_n_Matrix[0] n, n_error = Regression_Fit[1], m_n_Matrix[1] if errors_output: return m, m_error, n, n_error else: return m, n
def linfit_regression(self): fit_dict = OrderedDict() fit_dict['methodology'] = 'Linfit' Regression_Fit, Uncertainty_Matrix, fit_dict['red_ChiSq'], fit_dict['residuals'] = linfit(x_true = self.x_array, y = self.y_array, sigmay = self.y_error, relsigma = False, cov = True, chisq = True, residuals = True) m_n_Matrix = [sqrt(Uncertainty_Matrix[t,t]) for t in range(2)] fit_dict['R_factor'] = Uncertainty_Matrix[0,1]/(m_n_Matrix[0]*m_n_Matrix[1]) fit_dict['m'], fit_dict['m_error'] = Regression_Fit[0], m_n_Matrix[0] fit_dict['n'], fit_dict['n_error'] = Regression_Fit[1], m_n_Matrix[1] return fit_dict