/******************** (C) COPYRIGHT 2020 Geek************************************ * File Name : pdr_linearFit.h * Department : Sensor Algorithm Team * Current Version : V2.0(compare QCOM SAP 5.0) * Author : logzhan * Date of Issued : 2020.7.4 * Comments : PDR 线性拟合相关函数支持 ********************************************************************************/ #ifdef __cplusplus extern "C" { #endif #ifndef _PDR_LINEAR_FIT_H_ #define _PDR_LINEAR_FIT_H_ /**---------------------------------------------------------------------- * Function : pdr_linearLeastSquaresFitting * Description : 线性最小二乘拟合 Y = c0 + c1 x 目标函数为sum| nDataY - (a*nDataX+b)|^2最小 * Date : 2020/7/4 logzhan *---------------------------------------------------------------------**/ int linearLeastSquaresFit(const double *nDataX, const double *nDataY, const int nLength, double *a, double *b); /************************************************************************** * Description : 二维坐标系点的线性拟合,ax+by+c=0, 目标函数为点到拟合直线的距离 平方和最小 * Input : x, y,二维坐标X和Y num, 二维点个数 * Output : para, 拟合直线参数, para[0]:a, para[0]:b, para[0]:c **************************************************************************/ int leastDistanceLinearFit(double x[], double y[], int num, double para[]); /**---------------------------------------------------------------------- * Function : gsl_fit_linear * Description : Fit the data (x_i, y_i) to the linear relationship Y = c0 + c1 x returning, c0, c1 -- coefficients cov00, cov01, cov11 -- variance-covariance matrix of c0 and c1, sumsq -- sum of squares of residuals This fit can be used in the case where the errors for the data are uknown, but assumed equal for all points. The resulting variance-covariance matrix estimates the error in the coefficientsfrom the observed variance of the points around the best fit line. * Date : *---------------------------------------------------------------------**/ static int gslFitLinear(const double* x, const size_t xstride, const double* y, const size_t ystride, const size_t n, double* c0, double* c1, double* cov_00, double* cov_01, double* cov_11, double* sumsq); #endif // !_LINEAR_FITTING_H_ #ifdef __cplusplus } #endif