## 4 Threading Statistical Disclosure Attack Algorithm with EM (TSDA-EM)
### Removing Unnecessary Values with Proposed Tables
#### 4.4.2 Proposed Tables  
The proposed tables are auxiliary tables that help to infer real communication. Once we have the \(\lambda_{s,r}\) values, we use an algorithm to generate random values based on the \(\lambda_{s,r}\)'s [40]. Since the algorithm is based on a Poisson distribution, it is important to iterate the EM algorithm to refine the values of \(\lambda_{s,r}\). There are two different ways to iterate the TSDA-EM algorithm:  
* Reuse previously generated feasible tables: The distribution will not vary due to the constant values of the feasible tables, but it may be difficult to store all these tables. * Generate new feasible tables at each iteration: The distribution will vary depending of the feasible tables, but these will be deleted after they have been used. Since the number of rounds and tables can be high, we have decided to follow the second option. That is, generate the feasible tables, compute \(\lambda_{s,r}\), and then drop all these tables. Our problem is based on a defined period of time, that is, a mix network by either number of messages or a certain amount of time. We say there were exactly \(n\) number of messages sent or delivered during one unit of time (which follows a \(\lambda_{s,r}\)) where the inter times \(T_{1},T_{2},...\) are exponentially distributed with the rate \(\lambda_{s,r}\). It can be interpreted as the number of messages sent or received from a Poisson arrival process in one unit of time. And following these ideas, there is a relationship between the Poisson distribution and the exponential distribution. There were \(n\) number of messages during one unit of time, but the \(n\)th message occurred before time \(1\); the event \((n+1)\)st occurred after time \(1\). It meansthe sum of the times \(T_{1},\ldots,T_{n}\) belongs to the first unit of time, while the sum \(T_{1},\ldots,T_{n+1}\) belongs to a second unit of time. \[T_{1}+T_{2}+\cdots+T_{n}\leq 1<T_{1}+T_{2}+\cdots+T_{n+1} \tag{6}\]  
Equation (6) can be expressed as  
\[\sum_{i=1}^{n}T_{i}\leq 1<\sum_{i=1}^{n+1}T_{i} \tag{7}\]  
As mentioned before, \(T_{i}\) represents the inter times between events (emission and receptions of messages), and it had an exponential distribution with rate \(\lambda_{s,r}\). We can use the cumulative distribution function in order to generate a probability. \[F_{T}(T_{i})=1-e^{-\lambda_{s,r}T_{i}}=P_{i} \tag{8}\]  
As \(P_{i}\) is the probability (it has a uniform distribution over interval \([0,1]\)) of the cumulative distribution function \(F_{T}(T_{i})\), we can generate its inverse \(F_{T}(T_{i})=P_{i}\) for \(T_{i}\) in terms of \(P_{i}\):  
\[T_{i}=F_{T}^{-1}(P_{i})=-\frac{1}{\lambda_{s,r}}ln(1-P_{i}) \tag{9}\]  
A common simplification of Equation (9) is to replace \(1-P_{i}\) by \(P_{i}\) to yield. Now we can define Formula:  
\[\sum_{i=1}^{n}-\frac{1}{\lambda_{s,r}}ln(P_{i})\leq 1<\sum_{i=1}^{n+1}-\frac{1}{ \lambda_{s,r}}ln(P_{i}) \tag{10}\]  
Finally, in order to simplify Formula (10), multiply by \(-\lambda_{s,r}\), use the fact that a sum of logarithms is the logarithm of a product, and then use relation \(e^{lnx}=x\) to obtain:  
\[\prod_{i=1}^{n}P_{i}\geq e^{-\lambda_{s,r}}>\prod_{i=1}^{n+1}P_{i} \tag{11}\]  
An acceptation-rejection technique to generate random values using Equation (11) with \(\lambda_{s,r}\) as a parameter is shown in [39]. It has three steps:  
* **Step 1** set \(n=0\), \(P=1\)
* **Step 2** Generate a random number \(P_{n+1}\) (over interval \([0,1]\)), and replace \(P\) by \(P*P_{n+1}\)
* **Step 3** If \(P<e^{-\lambda}\), then accept \(n\). Otherwise, reject the current \(n\), increase \(n\) by one and return to step 2. What these steps do is count the number, \(n\), of random values (probability \(P_{n+1}\)) generated and stop when the multiplication of these random values, \(P\), is less than \(e^{-\lambda_{s,r}}\), because this represents that an event occurred in the second unit of time (the right part of Equation (11)). Otherwise, we continue generating random values that belong to the first unit of time.