# Interval-Based LDA Algorithm for Electrocardiograms for Individual Verification
## 2 Materials and Methods
### Threshold Values for Classification
#### 2.3.2 Threshold of Angle Similarity: \(TH_{\theta}(i)\)  
We calculated the scatter within class representing the degree of dispersion in a class which is called intra-subject variability, and the scatter between classes representing the degree of dispersion between different classes, which is called inter-subject variability, to obtain \(TH_{\theta}(i)\)[43].  
**Step 1:** Consider a data set of \((x,y)\) and \((x,r)\) for a given \(i_{o}\in i\), where  
\[\begin{array}{l} x=\ \{\forall v\},\\ y=\ \left\{\phi_{c}^{A}(i_{o},v)\ \Big{|}\ i_{o}\in i,\ \forall v\right\} \text{ for a given class $c$}\\ r=\ \left\{\overline{\phi}^{A}(i_{o},v)\ \Big{|}\ i_{o}\in i,\forall v\right\} \end{array} \tag{14}\]  
**Step 2:** Calculate the scatter within class and scatter between classes of the dataset \((x,y)\) and \((x,r)\).  
\[\begin{array}{l} S_{W}=\ S_{(x,y)}+\ S_{(x,r)}\\ S_{(x,y)}=\sum\Big{(}y-u_{y}\Big{)}\Big{(}y-u_{y}\Big{)}^{T}\\ S_{(x,r)}=\sum\ (r-u_{r})(r-u_{r})^{T}\\ S_{B}=\Big{(}u_{y}-u_{r}\Big{)}\Big{(}u_{y}-u_{r}\Big{)}^{T}\end{array} \tag{15}\]  
where \(u_{y}\) and \(u_{r}\) indicates the mean of \(y\) and \(r\), respectively.  
**Step 3:** Calculate the weight vector matrix in terms of \(S_{W}\) and \(S_{B}\). Subsequently, use the eigenvector with the highest eigenvalue as the most discriminant projection vector.  
\[\begin{array}{l} W=\frac{S_{B}}{S_{W}}\\ WV=\lambda V\end{array} \tag{16}\]where \(V\) is the eigenvector when \(\lambda\) corresponds to the highest eigenvalue.  
Let's define \(\theta_{c}^{A}(i_{o})\) as the angle \(\theta\) of the \(x\)-axis to the most discriminant projection vector V of the dataset, \((x,y)\) and \((x,r)\).  
\[\theta_{c}^{A}(i_{o})=tan^{-1}(V) \tag{17}\]  
**Step 4:** Define \(\theta_{c}^{A}(i_{o})\) as the angle distance per interval between dataset \((x,y)\) and \((x,r)\) for a given \(c\) and \(\overline{i_{o}}\).  
We obtain:  
\[\begin{array}{l}\text{{TH}}_{\theta_{max}}(i_{o})=max\left\{\begin{array}[ ]{l}\theta_{c}^{A}(i_{o})\end{array}\right|\forall c\in\{0,1,\cdots C-1\} \\ \text{{TH}}_{\theta_{min}}(i_{o})=min\left\{\begin{array}{l}\theta_{c}^{A}(i_ {o})\end{array}\right|\forall c\in\{0,1,\cdots C-1\}\end{array}\right\}\end{array} \tag{18}\]  
and  
\[\begin{array}{l}\text{{TH}}_{\theta_{1}}(i_{o})=\mu_{\theta}^{A}(i_{o})+ \sigma_{\theta}^{A}(i_{o}),\text{ { TH}}_{\theta_{2}}(i_{o})=\mu_{\theta}^{A}(i_{o})-\sigma_{\theta}^{A}(i_{o}) \end{array} \tag{19}\]  
where  
\[\begin{array}{l}\mu_{\theta}^{A}(i_{o})=mean\left\{\begin{array}{l}\theta _{c}^{A}(i_{o})\end{array}\right|\forall c\in\{0,1,\cdots C-1\}\\ \sigma_{\theta}^{A}(i_{o})=std\left\{\begin{array}{l}\theta_{c}^{A}(i_{o}) \end{array}\right|\forall c\in\{0,1,\cdots C-1\}\end{array}\right\}\end{array} \tag{20}\]  
Similar to the amplitude distance \(\Delta\phi_{c}^{A}(i,v)\), the angle distance \(\theta_{c}^{A}(i_{o})\) is mostly between \(\text{{TH}}_{\theta_{1}}(i_{o})\) and \(\text{{TH}}_{\theta_{2}}(i_{o})\) and almost always between \(\text{{TH}}_{\theta_{min}}(i)\) and \(\text{{TH}}_{\theta_{max}}(i)\). Based on this process and the subsequent updating process, the range of the intra-subject variation can be determined and the advantage of the constantly changing ECG signal can be reaped, which is beneficial for the verification using ECG.