# On IoT-Friendly Skewness Monitoring for Skewness-Aware Online Edge Learning
## 3 Three Versions of Running Skewness and Efficient Calculation Methods
### Performance Comparison among the Three CSS Calculation Methods
#### 4.3.1 Experimental Preparation  
To help guide and replicate the experimental implementations, we also use a language-independent algorithm to describe the CSS calculation method developed in this research.  
First of all, by using the two auxiliary variables \(\mathbb{V}\) and \(\mathbb{S}\) in the equation systems (3) and (4), we further derive Equation (13) for calculating \(S_{n+1}\).  
\[S_{n+1}=\frac{(n+1)\cdot\mathbb{S}_{n+1}}{n\cdot(n-1)\cdot s_{n+1}^{3}}=\frac{ (n+1)\cdot\mathbb{S}_{n+1}}{n\cdot(n-1)(\sqrt{\frac{\mathbb{V}_{n+1}}{n}})^{3} }=\frac{(n+1)\cdot\sqrt{n}}{n-1}\cdot\frac{\mathbb{S}_{n+1}}{(\sqrt{\mathbb{V }_{n+1}})^{3}} \tag{13}\]  
Then, we follow GSL's naming convention to include temporary variables to design the corresponding algorithm, as shown in Algorithm 3.  
```
0: The incoming observation value \(x\).
0: Global Parameters: The current amount of observations \(n\), the sample mean mean of the current observation values, and the current values of auxiliary variables \(bbV\) (i.e., \(\mathbb{V}_{n}\)) and \(bbS\) (i.e., \(\mathbb{S}_{n}\)).
0: Output: Cumulative sample skewness of the \(n+1\) observations.
1:\(n\gets n+1\)\(\triangleright\) The new observation is counted.
2:\(delta\gets x-mean\)\(\triangleright\) i.e., \((\bar{x}_{n+1}-\bar{x}_{n})\) in Equation System (4).
3:\(delta\gets x-mean\)\(\triangleright\) i.e., \((x_{n+1}-\bar{x}_{n+1})\) in Equation System (4).
4:\(delta\_m\gets delta*delta2\)\(\triangleright\) i.e., \((\mathbb{V}_{n+1}-\bar{V}_{n})\) in Equation System (4).
5:\(bbS\gets bbS-3*delta\_n*bbV+delta\_m*(delta2-delta\_n)\)
6:\(bbV\gets bbV+delta\_m\)
7:if\(n>2\)and (optionally) not in a chunk then
8:\(fac\gets n*\sqrt{n-1}/(n-2)\)
9:return\(fac*bbS/(\sqrt{bbV})^{3}\)
10:else
11:return\(0\)\(\triangleright\) Numeric \(0\) or Boolean false depending on contexts.
12:endif
```  
**Algorithm 3** Cumulative Sample Skewness in this Research  
Since these three algorithms have the same time complexity, we employ _running time_ as the metric to compare their performances. To facilitate \"apple-to-apple\" comparison and the following visualization, we implemented all the algorithms into Python (version 3.7.6) programs on a machine with Intel(R) Core(TM) i7-8550U CPU. @ 1.80 GHz and 8 GB RAM. The benchmark dataset (price2.txt shared at [[http://doi.org/10.5281/zenodo.4583508](http://doi.org/10.5281/zenodo.4583508)]([http://doi.org/10.5281/zenodo.4583508](http://doi.org/10.5281/zenodo.4583508)), accessed on 10 August 2021) is composed of 9,089,285 price records in total from Amazon's spot service price history, and we used different amounts of price records as different sample sizes to test the performances of the three Python programs. In addition to varying sample sizes, we further distinguish between two types of workloads:* The first workload type is to process data one by one. In this research, the programs screen the sample dataset and return the updated CCS value right after every single new price record is included in the processing.
* The second workload type is to process data chunk by chunk. In this research, the programs return the updated CSS value after every \(a\) new price records are included in the processing, while skipping the skewness calculation within the update intervals (i.e., supplementing \(n\%\)\(a==0\) to the if statement in all the algorithms). Note that the intermediate variables outside the if-else block are still updated continuously when screening the sample dataset.