# Intrusion Detection Based on Gray-Level Co-Occurrence Matrix and 2D Dispersion Entropy
## 3 Methodology and Materials
### Two dimensional Dispersion Entropy  
Two dimensional dispersion entropy (2 DDE) was introduced by [PERSON] and others in [PERSON] and others (2018) where it is described in detail. Here, we provide a brief description of the 2 DDE measure with reference to the IDS problem. 2 DDE is an extension of the one dimension dispersion entropy, which has demonstrated its superior performance in many problems (Kal  
\[y_{i,j}=\frac{1}{\sigma\sqrt{2\pi}}\int_{-\infty}^{x_{i,j}}e^{\frac{-(t-x)^{2}}{2 \sigma^{2}}}dt \tag{1}\]  
where \(\mu\) and \(\sigma\) are the average and standard deviation of U. The concept of Dispersion Entropy (even the one in one dimension) is related to the patterns of the embedding dimension \(m\) (another hyperparameter in the definition of 2 DDE). The dispersion patterns are created in the following way. First, a new matrix \(z\,z_{k,l}^{m,c}\) is created from \(y_{i,j}\) using the following equations (this is the adaption of Equation (2) from [4] taking in consideration that \(w\) and \(h\) from (2) are equal to \(Q_{F}\) in this case):  
\[z_{k,l}^{c}=round(c\times y_{i,j}+0.5) \tag{2}\]  
where \(z_{k,l}^{c}\) shows the \((i,j)\)th of the classified image and rounding involves either increasing or decreasing a number to the next digit. Second, \(z_{k,l}^{m,c}\) are made with the embedding dimension vector according to the following equation. \[z_{k,l}^{m,c}=z_{k,l}^{c},z_{k,l+1}^{c},z_{k,l+2}^{c},...,z_{k,l +(m_{Q_{F}}-1)}^{c}\\ z_{k+1,l}^{c},z_{k+1,l+1}^{c},z_{k+1,l+2}^{c},...,z_{k+1,l+(m_{Q_ {F}}-1)}^{c},...\\ z_{k+(m_{Q_{F}}-1),l}^{c},z_{k+(m_{Q_{F}}-1),l+1}^{c},z_{k+(m_{Q_ {F}}-1),l+2}^{c}...,z_{k+(m_{Q_{F}}-1),l+(m_{Q_{F}}-1)}^{c} \tag{3}\]  
where \(k\), \(l=1\), \(2\),...,\(Q_{F}-(m_{Q_{F}}-1)\). Third, each term of the matrix \(z_{k,l}^{m,c}\) is mapped to a dispersion pattern \(\pi_{v_{j}}\) on which the final entropy measure 2 DDE is calculated in the following way. Fourth, for each \(c^{m_{Q_{F}}m_{Q_{F}}}\) potential dispersion pattern \(\pi_{v_{0},v_{1},...,v_{(m_{Q_{F}-1})}}\), the relative frequency \(\pi_{v_{0},v_{1},...,v_{(m_{Q_{F}-1})}}\) in the image Y is calculated. Finally, the Shannon entropy is calculated on the dispersion pattern \(\pi_{v_{0},v_{1},...,v_{(m_{Q_{F}-1})}}\) to provide the 2 DDE according to the following equation:  
\[2 DDE(m,c)=-\sum_{\pi=1}^{c^{m_{Q_{F}}\times m_{Q_{F}}}}p(\pi_{v_ {0},v_{1},...,v_{(m_{Q_{F}}-1)}}\times(m_{Q_{F}-1}))\\ \times ln\left(p\left(\pi_{v_{0},v_{1},...,v_{(m_{Q_{F}}-1)}} \times(m_{Q_{F}-1})\right)\right) \tag{4}\]  
As in one dimension dispersion entropy, the value of the parameters \(m\) and \(c\) should be tuned to achieve an optimal performance (in this case, the detection of the attack). On the other side, the parameters \(m\) and \(c\) are bound [4] by the size of the time series on which 2 DDE has to operate. As described in [27] even for the one dimension dispersion entropy, to work with reliable statistics when calculating dispersion entropy, it is suggested that the number of potential dispersion patterns \(c^{m}\) is smaller than the length of the signal. In the two dimensional case, the rule reported in [4] and adapted for this case where the GLCM is square of size \(Q_{F}*Q_{F}\), is that \((c^{m_{Q_{F}}})^{2}<(Q_{F}-m_{Q_{F}}-1)^{2}\), which limits the space of the values of \(m\) and \(c\) to few values as the range of \(Q_{F}\). Considering that the range of \(Q_{F}\) spans from 12 to 48 in this study, the combinations of \(c=2\), \(m=3\) and \(c=3\), \(m=2\) are chosen. It must also be taken in consideration that higher values of \(m\) increase the computing time, which is not desirable for a large data set like the one used in this study. As pointed out in the Introduction, the rational for using 2 DDE in this study is that 2 DDE allows to analyze irregularity of images on the basis of the frequency of the dispersion patterns in the image [4], which can provide more information than the classical Shannon Entropy.