# CrowdPower: A Novel Crowdsensing-as-a-Service Platform for Real-Time Incident Reporting
## 3 System Architecture and Design
### Estimation of Data Quality, Participant's Reputation, and Filtering Outliers
#### 3.7.1 Quality Estimation Model  
This process is completed in the Data Analysis component in CrowdPower, which receives the sensory data from the selected participants, evaluates the data quality and reputations, then filters out the suspected malicious data providers. This would result in arriving at a better estimation of the actual sensory data. As a preprocessing step, if there are missing values in the time slots, then these values are filled as the average value of data received from a phone. For a time-slot \(k,1\leq k\leq K\), within a sensing campaign, the set of data received from the participants is \(D_{k}=\left\{d_{1,k},\ldots,\ d_{n,k}\right\}\). The quality of the data received is a set \(Q_{k}=\left\{q_{1,k},\ldots,\ q_{n,k}\right\}\).  
The set of sensory data \(D_{k}\) forms a cluster, and the distance between any two data points is represented as \(dist\left(d_{i,k},\ d_{i,k}\right)\). The MSaaS platform calculates the distance between the two data points to determine the similarity where the lesser the distance between two data items, the higher the similarity. While calculating the distance between the data values, the cluster centroid \(c_{k}\) is also determined by recalculating the centroid while iterating through the data. The deviation \(\delta_{i,k}\) shown in Equation (9) is the weighted square distance between \(c_{k}\) and the participant's data. The higher quality data are closer to the centroid and therefore have less deviation. The centroid is the minimum of the sum of the weighted squared distance between \(c_{k}\) and the participant's data as shown in Equation (10).  
\[\delta_{i,k}=dist^{2}(c_{k},\ d_{i,k}) \tag{9}\]  
\[c_{k}=argmin\sum\limits_{i=1}^{n}\delta_{i,k}\times q_{i,k} \tag{10}\]  
Now, let \(\lambda\) be the sum of all the deviations, i.e., \(\lambda=\sum\limits_{i=1}^{n}\delta_{i,k}\). The data quality is continuously updated as shown in Equation (11). The quality estimation \(q_{i,k}\) is a real number between 0 and 1, and the sum of all quality estimations is 1. The evaluation converges by comparing participants' quality variation between two consecutive iterations.  
\[q_{i,k}=\frac{\frac{1}{\frac{\gamma_{i,k}}{\lambda}+\epsilon}}{\sum\limits_{ j=1}^{n}\left(\frac{1}{\frac{\gamma_{i,k}}{\lambda}+\epsilon}\right)} \tag{11}\]  
The algorithm for quality estimation is provided in Algorithm 1. The input to the algorithm is the sensory data that are received by the Data Analysis component. The threshold_ is a small value used to differentiate two consecutive quality readings, where \(qp_{i,k}\) is the previous reading. The first loop in the algorithm is for initializing the quality outcome to 1/n, where n is the number of participants. The iterative loop in Line 3 of the algorithm converges with quality values for the data in a time slot. The loop recalculates the centroid as the sum product of the squared distance and quality output to determine the minimum distance to the centroid. The sum of all deviations \(\lambda\) is determined in Line 7. The new quality output is calculated in Line 9. The result is a set of quality values for the data submitted by the sensors on the participant's devices.  
```
Input: Data set: \(d_{i,k}\),threshold Output: Quality of participant data: \(Q_{k}\)
1. for all\(i\in N\)
2. \(q_{i,k}=\frac{1}{n}\)
3. for all\(i\in N\)&&\(\sum(qp_{i,k}-q_{i,k})\leq\textit{threshold}\)
4. \(c_{k}=argmin\sum_{i=1}^{n}dist^{2}(c_{k},\ d_{i,k})\times q_{i,k}\)
5. for all\(i\in N\)
6. \(\delta_{i,k}=dist^{2}(c_{k},\ d_{i,k})\)
7. \(\lambda=\sum_{i=1}^{n}\delta_{i,k}\)
8. for all\(i\in N\)
9. \(q_{i,k}=\frac{\frac{1}{\frac{1}{\delta_{i,k}}+\epsilon}}{\sum_{i=1}^{n}\left( \frac{1}{\frac{1}{\delta_{i,k}}+\epsilon}\right)}\)
10. return\(q_{i,k}\)
```  
**Algorithm 1**Quality Estimation