# Dual Auto-Encoder GAN-Based Anomaly Detection for Industrial Control System
## 4 Dual Auto-Encoder GAN-Based Anomaly Detection for Industrial Control System (DAGAN)
### DAGAN Model
#### 4.1.3 Parameter-Free Marginal Distribution Learning
The above strategy can help to better learn the marginal distribution of the for any industrial control dataset, avoid the misjudgment of outliers near the marginal region, and improve the accuracy of the model. (2) The second problem is how to determine the number of marginal samples in the dataset. To calculate the parameter \(\mu\), we need to determine the number of marginal points in the dataset. However, the industrial control system is difficult to model, so it is difficult to judge whether there are marginal samples in the large collected samples, and it is even more difficult to determine which ones are marginal samples. To solve this difficulty, this paper uses the Gaussian distribution to approximate the long-tail distribution of the real dataset. In the Gaussian distribution, the area of the \([c-2\sigma,c+2\sigma]\) is 95%, where \(c\) is the mean and \(\sigma\) is the standard deviation. For simplicity, this paper uses 5% as the cutoff to determine the number of marginal samples in a training dataset. The main reasons for using this strategy are as follows: Firstly, marginal samples are usually a very small proportion of the training dataset. Secondly, the average of the scores of multiple marginal samples is set as the parameter \(\mu\). Therefore, when the number of marginal points is large, a few more points and a few less points have little effect on the average of all points. Thirdly, when the proportion of marginal points is less than or more than 5%, those points that are over-computed or under-computed have very close D-Scores and do not have much impact on the average of all points. Therefore, based on this strategy, it is very easy to obtain the marginal points for any dataset. Figure 4: Optimization strategy for threshold \(\mu\). (3) The third question is how to quickly calculate the discriminator score (D-Score) for each marginal point. To calculate the parameter \(\mu\), we also need to know the discriminator score for each marginal point. The most direct and simple way is to train a binary classifier on the real dataset, then score all samples, and regard the samples with the smallest score as the marginal samples. However, this strategy requires additional training of a binary classifier, which is very time consuming. To solve this difficulty, this paper tries to use the process of learning normal distribution in the DAGAN model to help quickly calculate the D-Score for marginal points. The idea is that each time the first GAN is trained, the discriminator in the first GAN is used to calculate the D-Score of the marginal samples in the second GAN. In the first stage, the discriminator in the first GAN is not stable, so the obtained D-Scores of marginal points will be biased. As the number of training increases, the discriminator in the first GAN will gradually stabilize and the D-Scores of these marginal points in the second GAN will gradually converge. Based on this strategy, we can not only accurately obtain the D-Score of each marginal sample in the second GAN, but also greatly reduce the training time of our DAGAN model. In summary, a discriminator score-based parameter-free marginal distribution learning strategy is developed in this paper. The process of this strategy is shown in Figure 5, which includes the following three steps. Step 1 is initialization (\(t=0\)). The weights of the two GANs in the DAGAN model are randomly initialized and take 5% of the total number of samples in the training set as the number of marginal samples (\(MN\)). Step 2 is dynamic interaction between two GANs (\(t=1\) to \(t=\text{S}\)). At \(t=1\), the first GAN is trained with the training dataset. After the training is completed, the discriminator \(D_{1}\) is used to score all samples, the top-\(MN\) samples with the smallest scores are seen as marginal samples to calculate the \(\mu\), and the \(\mu\) as a parameter is inputted into the second GAN. Based on the \(\mu\), the second GAN starts training to learn marginal distribution.