66 lines
2.3 KiB
C
66 lines
2.3 KiB
C
|
/******************** (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 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>غ<EFBFBD><EFBFBD><EFBFBD>֧<EFBFBD><EFBFBD>
|
|||
|
********************************************************************************/
|
|||
|
#ifdef __cplusplus
|
|||
|
extern "C" {
|
|||
|
#endif
|
|||
|
|
|||
|
#ifndef _PDR_LINEAR_FIT_H_
|
|||
|
#define _PDR_LINEAR_FIT_H_
|
|||
|
|
|||
|
/**----------------------------------------------------------------------
|
|||
|
* Function : pdr_linearLeastSquaresFitting
|
|||
|
* Description : <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Y = c0 + c1 x
|
|||
|
Ŀ<EFBFBD>꺯<EFBFBD><EFBFBD>Ϊsum| nDataY - (a*nDataX+b)|^2<EFBFBD><EFBFBD>С
|
|||
|
* Date : 2020/7/4 logzhan
|
|||
|
*---------------------------------------------------------------------**/
|
|||
|
int linearLeastSquaresFit(const double *nDataX, const double *nDataY,
|
|||
|
const int nLength, double *a, double *b);
|
|||
|
|
|||
|
/**************************************************************************
|
|||
|
* Description : <EFBFBD><EFBFBD>ά<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD>ax+by+c=0, Ŀ<EFBFBD>꺯<EFBFBD><EFBFBD>Ϊ<EFBFBD>㵽<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD>ߵľ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
ƽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
|
|||
|
* Input : x<EFBFBD><EFBFBD> y<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ά<EFBFBD><EFBFBD><EFBFBD><EFBFBD>X<EFBFBD><EFBFBD>Y
|
|||
|
num, <EFBFBD><EFBFBD>ά<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* Output : para<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD>߲<EFBFBD><EFBFBD><EFBFBD>, 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
|