# Characteristics and Causes of Coastal Water Chemistry in Qionghai City, China
## 2 Materials and Methods
### Analytical Methods and Quality Assurance  
In this paper, the water chemistry data were counted by Excel and mathematical statistics, Pearson correlation analysis, Piper's trilinear diagram, and Gibbs diagram were used to analyze the water chemistry characteristics and control factors in combination with hydrogeological conditions in the study area. Among them, Piper trilinear plots and Gibbs plots were developed using Origin 2020, and inter-ion correlations were analyzed using SPSS 22 statistics.  
The Pearson correlation coefficient, also known as the product difference correlation coefficient, is a statistical indicator that expresses the degree and direction of linear correlation between the two variables. The correlation coefficient of a sample is denoted by the symbol \(\mathbf{r}\) and is calculated by the following formula [23; 24]:  
\[r=\frac{\sum\limits_{\langle X-\overline{X}\rangle}(Y-\overline{Y})}{\sqrt{ \sum\limits_{\langle X-\overline{X}\rangle^{2}}\sum\limits_{\langle Y- \overline{Y}\rangle^{2}}}}=\frac{l_{XY}}{\sqrt{l_{XX}l_{YY}}} \tag{1}\]  
\[l_{XX}=\big{(}X-\overline{X}\big{)}^{2}=\sum X^{2}-\frac{(\sum X)^{2}}{n} \tag{2}\]  
\[l_{YY}=\big{(}Y-\overline{Y}\big{)}^{2}=\sum Y^{2}-\frac{(\sum Y)^{2}}{n} \tag{3}\]  
\[l_{XY}=\sum\big{(}X-\overline{X}\big{)}\big{(}Y-\overline{Y}\big{)}=\sum XY- \frac{(\sum X)(\sum Y)}{n} \tag{4}\]  
where \(l_{YY}\) denotes the off-average sum of squares for \(X\); \(l_{YY}\) denotes the off-average sum of squares for \(Y\); \(l_{XY}\) denotes the off-average sum of squares for \(X\) and \(Y\); [PERSON]'s correlation coefficient is a dimensionless statistical indicator with a range of \(-1\leq r\leq 1\). A correlation coefficient less than 0 is a negative correlation, greater than 0 is a positive correlation, and equal to 0 indicates no correlation.  
The larger the absolute value of the correlation coefficient, the closer the correlation between the two variables. To determine whether there is a linear relationship, the researcher needs to look at the scatter plot of the two variables; if the scatter plot is roughly a straight line, it indicates a linear relationship, and if it is not a straight line, there is no linear relationship.  
The cluster analysis K-means algorithm, also known as the K-means clustering algorithm, is a widely used clustering algorithm that is the basis for other clustering algorithms [25; 26]. Assuming that the input samples are \(S=X_{1}\), \(X_{2}\), \(\cdots\), \(X_{m}\), the algorithm steps are as follows: (1) select the initial k category centers \(\mu_{1}\), \(\mu_{2}\), \(\ldots\)\(\mu_{k}\); (2) for each sample \(X_{i}\), mark it as the closest category to the category center (distance can be calculated using Euclidean distance); (3) update each category center to the mean of all samples belonging to that category; (4) repeat the last two steps until the centroid is unchanged or a predetermined number of iterations is reached, and the algorithm terminates.  
The objective function of the K-means algorithm is the within-cluster sum of squared errors (\(SSE\)), also known as cluster inertia.  
\[SSE=\sum\limits_{i=1}^{n}\sum\limits_{j=1}^{k}w^{(i)}\|x^{i}-\mu^{j}\|^{2} \tag{5}\]  
where \(w^{(i,j)}=1\) if \(x^{i}\) belongs to cluster \(j\). Otherwise, it is 0.