# On IoT-Friendly Skewness Monitoring for Skewness-Aware Online Edge Learning
## 3 Three Versions of Running Skewness and Efficient Calculation Methods
### The CSS Calculation Method from a Go Library  
Although not specified by GSL, according to Equation System (11), the GSL method corresponds to the Fisher-Pearson coefficient of skewness. To reinforce the comparison results, we further identified an online statistical library written in Go (GoL) (an open-source Go library for online statistical algorithms at [[https://github.com/alexander-yu/stream](https://github.com/alexander-yu/stream)]([https://github.com/alexander-yu/stream](https://github.com/alexander-yu/stream)), accessed on 10 August 2021), which employed the adjusted Fisher-Pearson coefficient of skewness. Despite the generic algorithms (45) cited by GoL, we also extract a skewness-specific equation system from GoL's source code, as shown in Equation System (12), in order to facilitate the formula comparison. \[ \begin{split}&\bar{x}_{n+1}=\bar{x}_{n}+\frac{x_{n+1}-\bar{x}_{n}}{n +1},\qquad\bar{x}_{0}=0,\ n>2\\ & C2_{n+1}=C2_{n}+\frac{n\cdot(x_{n+1}-\bar{x}_{n})^{2}}{n+1}, \qquad C2_{0}=0\\ & C3_{n+1}=C3_{n}-3\cdot\frac{x_{n+1}-\bar{x}_{n}}{n+1}\cdot C2_{ n}+\frac{n\cdot(n-1)}{(n+1)^{2}}\cdot(x_{n+1}-\bar{x}_{n})^{3},\qquad C3_{0}=0\\ & S_{n+1}=\frac{\sqrt{n\cdot(n+1)}}{n-1}\cdot\frac{\frac{C3_{n+1 }}{n+1}}{(\sqrt{\frac{C2_{n+1}}{n+1}})^{3}}\end{split}  \tag{12}\]  
In addition to the same notations \(x\), \(\bar{x}\), and \(S\) used in Equation System (11), we define \(C2\) and \(C3\) as two auxiliary variables in this equation system, by referring to Core.sums[2] and Core.sums[3], respectively, in the source code of GoL. By contrasting between the equation systems (12) and (11), it is clear that \(C2\) and \(C3\) are exactly the same as \(M2\) and \(M3\) for tracking the second and the third central moments, while only the calculations of \(S_{n+1}\) are different. (The equation for calculating \(S_{n+1}\) in Equation System (12) is extracted from the code Line 96 to Line 105 of skewness.go at [[https://github.com/alexander-yu/stream/blob/master/moment/skewness.go](https://github.com/alexander-yu/stream/blob/master/moment/skewness.go)]([https://github.com/alexander-yu/stream/blob/master/moment/skewness.go](https://github.com/alexander-yu/stream/blob/master/moment/skewness.go)), accessed on 10 August 2021). Similarly, we follow GSL's code optimisation strategy to describe the GoL method's CSS calculation into Algorithm 2. Note that similar temporary variables are used in this algorithm. Moreover, we use \(C2/n\) and \(C3/n\) respectively to replace the calculations of variables variance and moment (i.e., \(\frac{n}{n+1}\cdot\frac{C2}{n}\) and \(\frac{n}{n+1}\cdot\frac{C2}{n}\)) in the source code, for the convenience of algorithm comparison. This replacement does not have a negative impact on the representation of the original algorithm in GoL, because the simplified math operations have even improved the algorithm efficiency. ```
1:Input: The incoming observation value \(x\). Global Parameters: The current amount of observations \(n\), the sample mean mean of the current observation values, and the current values of auxiliary variables \(C2\) (i.e., Core.sums[2]) and C3 (i.e., Core.sums[3]). Output: Cumulative sample skewness of the \(n+1\) observations. 2:\(n\gets n+1\)\(\triangleright\) The new observation is counted. 3:\(delta\_{n}\gets delta/n\)\(\triangleright\) i.e., \((x_{n+1}-\bar{x}_{n})\) in Equation System (12). 4:\(term1\gets delta*delta\_n*(n-1)\)\(\triangleright\) i.e., \(\frac{n\cdot(x_{n+1}-\bar{x}_{n})^{2}}{n+1}\) in Equation System (12). 5:\(mean\gets mean+delta\_n\)\(\triangleright\) i.e., \(\frac{n\cdot(x_{n+1}-\bar{x}_{n})^{2}}{n+1}\) in Equation System (12). 6:\(C3\gets C3-3*delta\_n*C2+term1*delta\_n*(n-2)\)
7:\(C2\gets C2+term1\)
8:if\(n>2\)and(optionally) not in a chunkthen
9:\(fac\leftarrow\sqrt{n*(n-1)}/(n-2)\)\(\triangleright\) i.e., adjust in the code. 10:return\(fac*C3/n/(\sqrt{C2/n})^{3}\)\(\triangleright\) variance and moment in the source code have been simplified as \(C2/n\) and \(C3/n\) here.