{'fraction_non_alphanumeric': 0.024666666666666667, 'fraction_numerical': 0.02080952380952381, 'mean_word_length': 4.649986548291633, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Prediction Studies of River Water Quality Based on Moving Average Weighted Markov Model -- A Case Study of Shiwei Port, Jingjiang City

It is of great significance to predict the change trend of river water quality and comprehensively prevent and control river pollution for the protection of water quality of the Yangtze River and the implementation of "to step up conservation of the Yangtze River and stop its over development". Shiwei Port of Jingjiang City is located in the middle of Jingjiang City. It runs from north to south, connects the Jingtai Boundary River in the north, and enters the Yangtze River in the south. It is a first-class tributary of the Yangtze River. Based on the Moving Average Weighted Markov Model, this paper conducts an applied research on the water quality of Shiwei Port flowing into the Yangtze River. It is found that with the increase of the moving step, the accuracy of the moving prediction increases gradually, and the highest accuracy of the moving prediction is 24.9% compared with the original data, which shows that the moving average is necessary for the weighted Markov water quality prediction. Finally, the problems of the prediction model are analyzed and discussed, and the corresponding suggestions for the water quality and environmental management of Jingjiang City where Shiwei port is located are put forward, which can provide reference for the water quality management of other cities on both sides of the Yangtze River.


Introduction
With the rapid development of social economy and the acceleration of urbanization, the people's awareness of water resources' utilization and protection has been significantly improved. The water quality of the Yangtze River has a direct impact on the development of industry, agriculture and service industry in the cities on both sides of the Yangtze River. It is of great significance to manage and protect the water quality of the Yangtze River for the sustainable development of the society and economy of the Yangtze River Economic Belt and the implementation of the principle of "to step up conservation of the Yangtze River and stop its over development". According to the data released by the Yangtze River Water Conservancy Commission in 2019, the total annual discharge of sewage and waste water in the Yangtze Valley had reached 33.88 billion tons, equivalent to the annual runoff of the Yellow River. From 2003 to 2017, the water quality of the main stream of the Yangtze River was basically above the Class III standard [1]. In 2017, the river length of the Yangtze River reaching Class I and Class II standards was the largest, accounting for 73.0%. According to the statistics of relevant data, the main stream of the Yangtze River has more than 700 first-class tributaries, including more than 40 tributaries with a drainage area of more than 10,000 square kilometers, nine tributaries with a drainage area of more than 50,000 square kilometers, and four tributaries with a drainage area of more than 100,000 square kilometers. Maintaining and managing the water quality of the tributaries of the Yangtze River can, to a great extent, prevent the water quality of the Yangtze River from deteriorating.
The prediction of water quality change trend is an important basis for maintaining and managing water quality. By prediction, the change trend of water environment quality can be understood, so as to take timely treatment measures to prevent river pollution. Water quality prediction model has attracted the attention of many researchers. Luigi Spezia et al [2] used the Hidden Markov Model to conduct prediction research on the water quality of 56 catchments from land to sea in Scotland. Khalil Arya, F et al [3] applied the First-Order Markov Model based on Copula to the Snowomish River in Washington State to predict the future water quality risk of the river through the univariate water quality time series of the river. Qiu Lin et al [4] used Weighted Markov Model to predict the water quality of East Lake based on the characteristics of dependent random variables in water pollution indexes, and used the proportion of each pollution index in water pollution to predict the water quality of East Lake by means of weighting, providing another way for water quality prediction. Zhang Ya et al [5] used the improved Markov Model to predict the water quality of plateau lakes in view of the lack of research algorithms, and the prediction's accuracy reached 83.33%. Other algorithms were introduced into Markov Model to improve the accuracy of Markov Prediction. Yu hui et al [6] introduced Gray-fuzzy Theory into the Markov Chain Model to predict the water quality of dissolved oxygen, potassium permanganate index and ammonia nitrogen of the Sanchakou Section in the Haihe River. Compared with the Original Residual GM (1, 1) Model, the GM (1, 1) -Markov Chain Prediction Model had a good prediction effect, but some errors were also found. Sun Leqiang et al [7] processed the original data with asynchronous moving average and then applied the Markov Model to predict the annual rainfall of Beijing and Nanjing. By applying the moving average processing of 3a, 5a and 7a, the accuracy of precipitation prediction was improved to 74%, 77% and 86% respectively. Wang Bei et al [8] applied the Moving Average Markov Chain Model, by calculating the Markov State Transition Probability and using the Fuzzy Set Theory to predict the precipitation of Shali Guilanco Hydrological Station in the Tuoshigan River, Xinjiang Uygur Autonomous Region with good prediction results. All the above literatures have studied the prediction model based on Markov Chain, and it can be seen that the Moving Average Method is well applied in the precipitation prediction, but there has been not much research on the influence of the moving average on the river water quality prediction. Therefore, it is necessary to study the prediction of river water quality by the moving average Weighted Markov Model and find out the general conclusion on the accuracy of the moving average to the Weighted Markov Model in predicting river water quality.
This paper is based on the moving average Weighted Markov Model, Shiwei Port (the river where New Shiwei Port Bridge is located), where Jingjiang City's state-controlled section and the national "Ten Items about Water" (abbreviation for Action Plan for Prevention and Control of Water Pollution) assessment section are located, is taken as an example to predict and study the river water quality. Shiwei Port is located in the center of Jingjiang City, running from north to south, connecting the Jingtai Boundary River in the north and the Yangtze River in the south. It is a first-class river course that runs through the urban area of Jingjiang City. See Figure 1 for its geographical location. In order to maintain and manage the water quality of the state-controlled section of New Shiwei Port Bridge, the possible river pollution can be prevented and resolved by accurately predicting the water quality change, which is of great significance to protect the water quality of the Yangtze River, and provides a basis for guiding the water quality management of other tributaries of the Yangtze River.

Moving Average Method
The moving average method is to calculate the moving average value of the observed data information before and after adding or deleting the data in time sequence, so as to realize the smoothness of the data, eliminate or reduce the accidental random factors, and find out the future trend of some phenomenon or something [7]. Therefore, the measured time series of river water quality change trend is used to calculate the moving average value, and the accidental fluctuation of river water quality is eliminated by moving average value, which makes the river water quality time series more smooth [8]. A simple moving average can be calculated from the following formula.
(1) Of which: t is the moving average of this period; is the number of periods of the moving average; is the measured river water quality of the current period; −1 , −2 and − are the measured values of river water quality in the previous 1st period, the previous 2nd period, and the previous th period.

Markov Chain Method
Markov Process is a random process used to study the state of an event and the transition rules between states. The most basic feature of this process is no aftereffect [4], that is, under the condition of a given time series determined by a random process, the probability of the occurrence of the next state is only related to the current state, and has nothing to do with the previous state(s) [9]. Markov Chain is a time series with discrete time and discrete state. In essence, Markov Model is based on Probability Theory and Stochastic Process Theory in mathematical statistics, and predicts the future change trend of things by analyzing the states of things in different periods [10]. It studies the state change of things at the moment 0 + through the probability distribution of the current state and the state transition probability. Let { ( ) , ∈ } be the random sequence, among them, = {0,1,2, ⋯ }, if the observed value 1 , 2 , ⋯ obtained from ( ) at the moment 1 , 2 , ⋯ satisfies the condition.
, and the probability of In the formula, , ( , + ) means "the probability with the state at the moment , which transits to state after step(s)"; , ( , + 1) represents the transition probability of Markov Chain from state to state by 1 step. All one-step transition probabilities can form one-step transition probability matrix for the current time series: In practical applications, only homogeneous Markov Chain is generally considered [11], and homogeneous Markov Chain satisfies the transition probability = 1 of k step(s). In order to make full and reasonable use of the probabilities of each state, the weight of different step lengths of this time series can be summed up with the weight of various prediction probabilities of the same state, and the sum can be regarded as the prediction probability of the water quality in this state [12].
The weight of Markov Chain with different step lengths can be obtained by calculating the k order autocorrelation coefficient of the measured value sequence of the original water quality, and then normalizing it. The autocorrelation coefficient can be obtained from the following formula.
In the above formula, is the actual monitoring value of a certain water quality index at the moment ; ̅ represents the average monitoring value of this water quality index at all moments. Finally, the state subjection of Markov Chain is determined by corresponding to { , ∈ }.

Verification of Moving Average -Weighted Markov Model
Based on the water quality monitoring data of New Shiwei Port Bridge (Shiwei Port Bridge) from 2014 to 2019, the following indicators are selected, including permanganate index, ammonia nitrogen, chemical oxygen demand, biochemical oxygen demand, total nitrogen and total phosphorus. In order to eliminate the impact of low flow period and high flow period on water quality monitoring and obtain the average change of water quality within a certain period, the average half-year measured water quality data of the above mentioned water quality indicators (such as the first half of 2018 (2018H1) and the second half of 2018 (2018H2)) are taken as an example (see Table 1) to predict the river water quality of Shiwei Port in 2019. Firstly, 10 groups of water quality index data from 2014H1 to 2018H2 are used to predict the water quality of 2019H1 by the prediction model to verify the accuracy of the model. Then the measured data of 2019H1 are added into the water quality time series to predict the water quality data of 2019H2.
(1) Water quality standard values of surface water as per environmental quality standard GB3838-88 are shown in Table 2. The water quality status of Shiwei Port is determined by the measured water quality values according to the above standards. The status is divided into six levels, which are expressed as Levels 1, 2, 3, 4, 5 and 6 (exceeding Class V standard), as shown in Table 3. (2) Considering the length of the time series of water quality in Shiwei Port and its practicability in the prediction model, this paper sets the maximum moving step as 5H (within half a year), and makes weighted Markov Prediction on the measured value of each water quality index in Shiwei Port of Jingjiang City as well as 2H, 3H and 5H. In order to make the sample number of different moving average processing steps consistent, for the Nth step moving processing, the processing value of the first N-1a is replaced by that of the 1st, 2nd,…,(N-1)th step, respectively. For example, for 2H moving, the 1st column of the sequence is replaced by the measured data, while the 2nd column is replaced by the mean value of the actual detected values in the 1st and 2nd columns, and so on.  3  1  3  3  6  3  2015H1  3  1  3  1  6  3  2015H2  2  1  2  1  6  3  2016H1  2  1  2  1  6  2  2016H2  2  1  2  1  6  2  2017H1  2  1  3  3  6  3  2017H2  3  1  3  3  6  3  2018H1  3  1  4  3  6  3  2018H2  2  1  2  3  5  3  2019H1  2  1  3  3  6  3 a. Firstly, according to the measured data of ammonia nitrogen from 2014H1 to 2018H2 in Table 1, the moving average values of 2H, 3H and 5H of ammonia nitrogen are calculated, and the corresponding water quality levels are calculated according to the surface water quality standards in Table 2, and are expressed as Levels 1, 2, 3, 4, 5 and 6 (exceeding Class V standard) respectively, as shown in Table 4.  b. The autocorrelation coefficient of each order was calculated under the measured value and the moving average of 2H, 3H and 5H for ammonia nitrogen (When there are enough water quality data, the greater the value of k, the higher the accuracy of the corresponding model prediction results, but at the same time, the amount of calculation will increase.) In this paper, k=5 is used to calculate and normalize the autocorrelation coefficients of each order, and then the Markov Weight of different steps is obtained. The results are shown in Table 5. c. According to the water quality level of the measured value of ammonia nitrogen (1H) in Table 4, the Markov Transfer Probability Matrix is calculated, and according to the corresponding weight in Table 5, the weight and of the measured value of ammonia nitrogen of water quality index are calculated. See Table 6. Similarly, the weight and of measured ammonia nitrogen values of water quality index under 2H, 3H and 5H moving average can be obtained, as shown in Table 7.  It can be seen from Table 7 that when the step is 1H, = II, = 0.4304 is the maximum value, which indicates that the ammonia nitrogen water quality index level in 2019H1 is Class 2 (II) under this step. In the same way, it can be concluded that the ammonia nitrogen of 2H moving average water quality index is Class II, and that of 3H and 5H moving average water quality index is Class III. Combined with Table 3, it can be seen that the predicted results of 3H and 5H moving average are the same as those measured in 2019.
(3) Repeat a~c and replace the original values corresponding to ammonia nitrogen index, biochemical oxygen demand, chemical oxygen demand, total nitrogen and total phosphorus and the moving values of 2H, 3H and 5H with those of potassium permanganate to obtain the transfer probability matrix and weighted sum of potassium permanganate index, biochemical oxygen demand, chemical oxygen demand, total nitrogen and total phosphorus. The maximum value of is respectively taken as the prediction result, as shown in Table 8.  Table 8 and the prediction results of ammonia nitrogen, it can be obtained after simple calculation that in the six water quality indexes of 2019H1, the accuracy of Markov prediction based on the original data is 66.7%, and the accuracy of 2H, 3H and 5H moving prediction is 50%, 66.7% and 83.3% respectively. The accuracy of 5H moving prediction is 24.9% higher than that of the original data. In general, with the increase of moving step, the accuracy of weighted Markov Prediction will improve, among which 5H moving average-weighted Markov is the most accurate to predict the water quality.
(4) Add measured water quality data of 2019H1 to the time series, repeat steps a~c, and perform 5H moving average-weighted Markov Prediction, and then the predicted values of each water quality index in 2019H2 can be obtained, as shown in Table 9.
It can be seen that the predicted states of potassium permanganate index, biochemical oxygen demand, ammonia nitrogen, chemical oxygen demand, total nitrogen and total phosphorus in 2019H2 belong to Classes III, I, III, III, worse than V and III, basically the same as all index states in 2019H1, which shows that the measures taken by the local government have had an effect and the river pollution is no longer getting worse. Although most of the water quality indexes of Shiwei Port are in Class III, ammonia nitrogen is of worse than V, which affects the overall water quality evaluation, loses the value as industrial and agricultural water and landscape water, and also has certain harm to the water quality of the Yangtze River.  It can be seen that the predicted states of potassium permanganate index, biochemical oxygen demand, ammonia nitrogen, chemical oxygen demand, total nitrogen and total phosphorus in 2019H2 belong to Classes III, I, III, III, worse than V and III, basically the same as all index states in 2019H1, which shows that the measures taken by the local government have had an effect and the river pollution is no longer getting worse. Although most of the water quality indexes of Shiwei Port are in Class III, ammonia nitrogen is of worse than V, which affects the overall water quality evaluation, loses the value as industrial and agricultural water and landscape water, and also has certain harm to the water quality of the Yangtze River.

Conclusion
Based on the Moving Average-Weighted Markov Chain Model, the water quality of Jingjiang City's Shiwei Port River which flows into the Yangtze River is predicted in this paper. The results show that the accuracy of the model is better than that of the traditional model, for the six indexes including permanganate index, biochemical oxygen demand, ammonia nitrogen, chemical oxygen demand, total nitrogen and total phosphorus, the accuracy of Markov prediction with original data was 66.7%, and the accuracy of 2H, 3H and 5H moving prediction was 50%, 66.7% and 83.3% respectively. The accuracy of 5H moving prediction is 24.9% higher than that of the original data. In general, the accuracy of weighted Markov Prediction increases with the increase of moving step. The autocorrelation coefficient of different steps is used as the weight of water quality prediction model, and the information of water quality time series data is also fully utilized. The method of moving average reduces the randomness of the measured water quality time series data and increases the accuracy of the prediction results to a certain extent. At the same time, we also found the following two problems: 1. Due to the limited length of the water quality time series data, the data cannot fully reflect the real situation of water quality. 2. The accuracy of the moving prediction of potassium permanganate index is not very good, which indicates that although the moving average conceals the randomness of the data, but reduces the real volatility of the data at the same time. In view of these two problems, increasing the length of time series and finding the appropriate average moving step may improve the accuracy of the model prediction, which needs further research.
According to the over standard of total nitrogen index in Shiwei Port and the basic situation of Jingjiang City where Shiwei Port is located, the reasons for the exceeding of the standard of total nitrogen may be the pollution of agricultural chemical fertilizer (nitrate nitrogen fertilizer), domestic sewage and aquaculture wastewater. The next step is to strengthen the guidance of the government and take the following measures: 1. Aiming at the agricultural chemical fertilizer pollution and excessive use of chemical fertilizer: Construct nitrogen and phosphorus ecological interception ditch, sewage purification pond, and collection and storage pool of surface runoff. 2. Aiming at the domestic pollution, domestic sewage and domestic solid waste of the residents: Strengthen the construction of centralized sewage treatment infrastructures, and improve the sewage collection rate and treatment rate. 3. Aiming at the aquaculture wastewater pollution: Focus on the aquaculture enterprises above the designated scale, construct professional sewage treatment plants, renovate the sewage outlets into the river, and work out a special rectification plan. Jingjiang City, where Shiwei Port is located, is a typical city along and in