## 3 Optimization Algorithms for Sliding Window Size  
Dixon detection can realize simple and efficient outlier detection by calculating the \(Q\) value and decision table when detecting small amounts of sample data [33]. The method used by [PERSON] et al. [27] realizes the detection application of a large sample size for long-term time series data through window sliding. In order to set the size of the sliding window reasonably and make the efficiency of outlier detection optimal, a new Monte Carlo algorithm is proposed in this paper. The new algorithm makes use of the advantages of computer random sampling and realizes the determination of the optimal sliding window size through the evaluation standard of detection rate. In order to quantitatively evaluate the accuracy and efficiency of the new algorithm, we selected the measured water quality time series data from the automatic monitoring station for the experimental verification and comparative analysis of the new algorithm. \begin{table}
\begin{tabular}{c c c c c c c c c c c c c c} \hline \hline \multirow{2}{*}{**Significance Level**} & \multicolumn{8}{c}{\(w\)} \\ \cline{2-13}  & **3** & **4** & **5** & **6** & **7** & **8** & **9** & **10** & **11** & **12** & **13** & **14** & **15** & **16** \\ \hline \(Q_{0.05}\) & 0.941 & 0.765 & 0.642 & 0.560 & 0.507 & 0.554 & 0.512 & 0.477 & 0.576 & 0.546 & 0.521 & 0.546 & 0.525 & 0.507 \\ \(Q_{0.01}\) & 0.988 & 0.889 & 0.780 & 0.698 & 0.637 & 0.683 & 0.635 & 0.597 & 0.679 & 0.642 & 0.615 & 0.641 & 0.616 & 0.595 \\ \hline \hline \multicolumn{13}{c}{\multirow{2}{*}{**Significance Level**}} & \multicolumn{8}{c}{\(w\)} \\ \cline{2-13}  & **17** & **18** & **19** & **20** & **21** & **22** & **23** & **24** & **25** & **26** & **27** & **28** & **29** & **30** \\ \hline \(Q_{0.05}\) & 0.490 & 0.475 & 0.462 & 0.450 & 0.440 & 0.431 & 0.422 & 0.413 & 0.406 & 0.399 & 0.393 & 0.387 & 0.381 & 0.376 \\ \(Q_{0.01}\) & 0.577 & 0.561 & 0.547 & 0.535 & 0.526 & 0.516 & 0.507 & 0.497 & 0.489 & 0.482 & 0.474 & 0.468 & 0.462 & 0.456 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Decision table for Dixon criterion detection threshold. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Sliding Window Size (\(w\))** & \(\Delta y\)**(\(t+w\)) Is a Dubious Value** & \(\Delta y\)**(\(t+1\))’ Is a Dubious Value** \\ \hline
3–7 & \(Q_{01}=\frac{\Delta y(t+w)^{\prime}-\Delta y(t+w-1)^{\prime}}{\Delta y(t+w)^{ \prime}-\Delta y(t+1)^{\prime}}\) & \(Q_{10}=\frac{\Delta y(t+2)^{\prime}-\Delta y(t+1)^{\prime}}{\Delta y(t+w)^{ \prime}-\Delta y(t+1)^{\prime}}\) \\ \hline
8–10 & \(Q_{11}=\frac{\Delta y(t+w)^{\prime}-\Delta y(t+w-1)^{\prime}}{\Delta y(t+w)^{ \prime}-\Delta y(t+2)^{\prime}}\) & \(Q_{11}=\frac{\Delta y(t+2)^{\prime}-\Delta y(t+1)^{\prime}}{\Delta y(t+w-1)^{ \prime}-\Delta y(t+1)^{\prime}}\) \\ \hline
11–13 & \(Q_{21}=\frac{\Delta y(t+w)^{\prime}-\Delta y(t+w-2)^{\prime}}{Considering that the probability of abnormal data is usually very small, the number of samples for random sampling to determine the optimal sliding window is required to be large enough so that the calculation results can meet the accuracy of the algorithm. Obviously, the larger the sample size, the lower the efficiency of the algorithm. In the design of the algorithm, it is recommended to select \([0.5n,0.8n]\) (\(n\) is the length of time series record) as the length for random sampling calculation during random sample selection. The algorithm flow and schematic diagram are shown in Figure 2.  
The determination criterion of the optimal window is determined by the maximum detection ratio of outlier data. The specific calculation is as follows:  
\[\left\{ \begin{array}{l}\mathop{\mathit{\mathrm{d}}r}(J,i)=max\bigg{(}\frac{ Y_{j}(i)}{n}\bigg{)},\ j\in[3,30];i=[0.5n,0.8n]\\ \mathop{\mathit{\mathrm{d}}w}=J\end{array} \right.