# SpecTalk: Conforming IoT Implementations to Sensor Specifications
## 5 Selection of the Frequency of the Control Signals in the IoT Device Test  
While one may attempt to quickly complete an IoT device test by selecting a high frequency of the control signal generation for the input pattern, such selection may result in incorrect test results. Consider the test in Figure 19, where the drip  
Figure 24: Visual-tests for analog meters. Figure 23: The visual-test configuration for a fountain in the Ming Der High School, Taichung. by the control signals issued from Switch-I1. Suppose that the dripper motor receives the \"on\" signal at \(\tau_{0}\) in Figure 25, and the motor is turned on at \(\tau_{*}\), then the activation delay of the motor is \(t=\tau_{*}-\tau_{0}\). The characteristics (the mean and the variance) of \(t\) for the actuator may be provided in the vendor's data sheet. Otherwise, we need to measure the operation delays. Such measurements can be simply conducted using the Network Time Protocol. If Switch-I1 continues to send the control signals at \(\tau_{1}\), \(\tau_{2}\),..., \(\tau_{n}\), \(\tau_{n+1}\), where \(\tau_{n}\leq\tau_{*}\leq\tau_{n+1}\), then the signals arrive at \(\tau_{2}\),..., \(\tau_{n}\) will be ignored and the motor will execute the instruction arrives at \(\tau_{n+1}\). Therefore, the inter-arrival times of the control signals should be longer than \(t\) to avoid producing incorrect test results. Let \(t_{i}=\tau_{i}-\tau_{0}\). We typically generate Poisson input patterns. That is, the inter-arrival times of the control signals have an Erlang distribution with the expected value \(\text{E}[t_{i}]=i/\lambda\). Then the density function \(g(t_{i})\) has an Erlang density function of  
\[g(t_{i})=\frac{\lambda^{i}t_{i}^{i-1}e^{-\lambda t_{i}}}{(i-1)!}\]  
Let \(t\) have a general density function \(f(t)\), then  
\[ \begin{array}{ll}\text{Pr}[t>t_{n}]&=\int_{t=0}^{\infty}f(t)\int_{t_{n}=t}^{ \infty}\Bigl{[}\frac{\lambda^{i}t_{n}^{i-1}e^{-\lambda t_{n}}}{(n-1)!}\Bigr{]} dt_{n}dt\\ &=\int_{t=0}^{\infty}f(t)\sum\limits_{i=0}^{n-1}\Bigl{[}\frac{\lambda^{i}f(t _{i}e^{-\lambda t}}{t}\Bigr{]}dt\\ &=\sum\limits_{i=0}^{n-1}\Bigl{(}\frac{\lambda^{i}}{t!}\Bigr{)}\int_{t=0}^{ \infty}t^{i}f(t)e^{-\lambda t}dt\end{array}  \tag{1}\]  
Let \(f^{*}(s)=\int_{t=0}^{\infty}f(t)e^{-\lambda t}\ dt\) be the Laplace Transform of \(f(t)\). Then, from the frequency-domain derivative of the Laplace Transform, Equation (1) is re-written as  
\[\text{Pr}[t>t_{n}]=\sum\limits_{i=0}^{n-1}\Bigl{(}-\frac{\lambda^{i}}{i!} \Bigr{)}\left[\frac{f^{*(i)}(s)}{ds^{i}}\right]\[PERSON]{|}_{s=\lambda} \tag{2}\]  
From Equation (2), we have  
\[\text{Pr}[t_{n}<t<t_{n+1}]=\left(-\frac{\lambda^{n}}{n!}\right)\left[\frac{f^ {*(n)}(s)}{ds^{i}}\right]\[PERSON]{|}_{s=\lambda} \tag{3}\]  
Equation (3) gives the probability that \(n-1\) consecutive control signals are ignored by the IoT DUT. The probability that no control signal is lost is \(\text{Pr}[t<t_{2}]\), which is expressed as  
\[ \begin{array}{l}\text{Pr}[t>t_{2}]=1-\text{Pr}[t<t_{2}]\\ =1-f^{*}(\lambda)+\lambda\left[\frac{f^{*}(s)}{ds}\right]\Bigr{|}_{s=\lambda} \end{array}  \tag{4}\]  
Figure 25: The timing diagram. If \(f(t)\) is a Gamma density function with the shape parameter \(\alpha\) and the scale parameter \(\beta\), then its Laplace transform is  
\[f^{*}(s)=\frac{\beta^{\alpha}}{\left(s+\beta\right)^{\alpha}} \tag{5}\]  
The Gamma distribution is considered because this distribution is often used in computer and communication modeling [26; 27]. Substitute Equation (5) to Equation (3) to yield  
\[\Pr[t_{n}<t<t_{n+1}]=\left( \begin{array}{c}\alpha+n\\ n\end{array} \right)\left(\frac{\lambda}{\lambda+\beta}\right)^{n}\left(\frac{ \beta}{\lambda+\beta}\right)^{\alpha} \tag{6}\]  
Substitute Equation (5) to Equation (4) to yield  
\[\Pr[t>t_{2}]=1-\frac{\beta^{\alpha}}{\left(\lambda+\beta\right)^{\alpha}}- \frac{\alpha\lambda\beta^{\alpha}}{\left(\lambda+\beta\right)^{\alpha+1}} \tag{7}\]  
In the Gamma distribution, a small \(\alpha\) implies a large variance of \(t\), and the operation of the DUT is not stable.