# A Regression-Based Technique for Capacity Estimation of Lithium-Ion Batteries
## 3 Capacity Estimation
### Proposed Methods to Estimate \(Q\)
#### 3.2.1 The First Type of Least Squares Method  
The standard (weighted least squares) linear regression is the first investigated method to solve the above equation. By considering \(\Delta y\) as the noise on measurement and uncertainties of \(y\), the form of the problem is:  
\[(y-\Delta y)=Qx \tag{16}\]  
In the above equation, \(\Delta y\) includes zero-mean Gaussian random variables with variances of \(\sigma_{y_{i}}^{2}\). The estimated \(Q\) could be shown by \(\hat{Q}\), then \(y\approx\ \hat{Q}x\), can be solved by using vectors of measured data of \(x\) and \(y\):  
\[x_{i}=SOC[k_{2,i}]-SOC[k_{1,i}] \tag{17}\]  
\[y_{i}=-\Delta t\sum_{k_{1},i}^{k_{2,i}-1}\eta[k]i_{b}[k] \tag{18}\]  
In this level, the \(\hat{Q}\) is estimated which minimizes the following first type of least-squares (LS1) cost function:  
\[\chi_{LS1}^{2}=\sum_{i=1}^{n}\frac{\left(y_{i}-Y_{i}\right)^{2}}{\sigma_{y_{i }}^{2}}=\sum_{i=1}^{n}\frac{\left(y_{i}-\hat{Q}x_{i}\right)^{2}}{\sigma_{y_{i }}^{2}} \tag{19}\]  
In which \(Y_{i}\) is the exact value of \(Y\) without noise (\(Y_{i}=\hat{Q}x_{i}\)). By differentiating the above cost function concerning \(\hat{Q}\) and setting it to zero, the following equations could be determined:  
\[\frac{\partial\chi_{LS1}^{2}}{\partial\hat{Q}}=-2\ \sum_{i=1}^{N}\frac{x_{i} \big{(}y_{i}-\hat{Q}x_{i}\big{)}}{\sigma_{y_{i}}^{2}}=0 \tag{20}\]  
\[\hat{Q}\ \sum_{i=1}^{N}\frac{x_{i}^{2}}{\sigma_{y_{i}}^{2}}=\sum_{i=1}^{N} \frac{x_{i}y_{i}}{\sigma_{y_{i}}^{2}} \tag{21}\]  
\[\hat{Q}=\sum_{i=1}^{N}\frac{x_{i}y_{i}}{\sigma_{y_{i}}^{2}}\ /\ \sum_{i=1}^{N}\frac{{x_{i}}^{2}}{\sigma_{y_{i}}^{2}} \tag{22}\]By defining \(C_{1}=\sum\limits_{i=1}^{N}\frac{x_{i}y_{i}^{2}}{\sigma_{y_{i}}^{2}}\) and \(C_{2}=\sum\limits_{i=1}^{N}\frac{x_{i}y_{i}}{\sigma_{y_{i}}^{2}}\), the following statement can be derived:  
\[\hat{Q}=\frac{C_{2}}{C_{1}} \tag{23}\]  
\(C_{1}\) and \(C_{2}\) could be updated recursively by the following equations. Those as mentioned above could be determined when each new (\(x_{i}y_{i}\)) datum is received:  
\[C_{1,n}=\sum\limits_{i=1}^{N}\frac{x_{i}^{2}}{\sigma_{y_{i}}^{2}}=C_{1,n-1}+ \frac{x_{n}^{2}}{\sigma_{y_{n}}^{2}} \tag{24}\]  
\[C_{2,n}=\sum\limits_{i=1}^{N}\frac{x_{i}y_{i}}{\sigma_{y_{i}}^{2}}=C_{2,n-1}+ \frac{x_{n}y_{n}}{\sigma_{y_{n}}^{2}} \tag{25}\]  
\[\hat{Q}_{n}=\frac{C_{2,n}}{C_{1,n}} \tag{26}\]  
Minimum storage requirement and computational load are advantages of the recursive manner in equations, and it is essential for implementing in BMS and other embedded units.  
By increasing the number of data pairs, data volumes are weighted, and new data pairs cannot significantly affect the results. Therefore, there is a need to change the method to fade older data pairs' power on results as the number of data pairs increases. Therefore, a coefficient such as \(0\ll\gamma<1\) can solve this issue:  
\[\widetilde{C}_{1,n}=\sum\limits_{i=1}^{n}\gamma^{n-i}\frac{x_{i}^{2}}{\sigma_{ y_{i}}^{2}}=\gamma\widetilde{C}_{1,n-1}+\frac{x_{n}^{2}}{\sigma_{y_{n}}^{2}} \tag{27}\]  
\[\widetilde{C}_{2,n}=\sum\limits_{i=1}^{n}\gamma^{n-i}\frac{x_{i}y_{i}}{\sigma _{y_{i}}^{2}}=\gamma\widetilde{C}_{2,n-1}+\frac{x_{n}y_{n}}{\sigma_{y_{n}}^{2}} \tag{28}\]  
This method (LS1) could be an acceptable method if there were no measurement noise or uncertainty of \(x_{i}\), but in reality, the error in SOC estimation will never be totally eliminated. The solution could be the second type of least squares.