# Low-Complexity Channel Codes for Reliable Molecular Communication via Diffusion
## 2 Materials and Methods
### Detection and Bit Decision  
In this paper, we assume that no channel state information (CSI) exists at the transmitter nor the receiver. Therefore, the detection is accomplished solely based on the received observations over each encoded block duration. Two simple detection approaches are considered. The first one is a threshold based detection similar to that in [14], which generates hard decision symbols/bits. We consider a concentration-based binary modulation where each symbol comprising codeword \(i\) is represented as \(x^{i}[k]\in\{A_{0},A_{1}\}\), with \(A_{0}\) and \(A_{1}\) denoting the levels for a '0' and a '1', respectively. In this case, an adaptive threshold is computed for the \(i\)-th codeword as  
\[t^{i}=ay^{i}_{min}+(1-a)y^{i}_{max} \tag{6}\]  
where \(y^{i}_{min}=min(y^{i})\) and \(y^{i}_{max}=\max(y^{i})\), with \(y^{i}=\left[y^{i}[1],\ldots,y^{i}[N]\right]^{T}\) denoting the vector with the corresponding \(N\) received samples. Parameter \(a\) is a scaling factor which, considering the adoption of a balanced code with equal number of 0's and '1's, we set as \(a=0.5\). Using this threshold, a hard decision estimate is simply obtained as  
\[\hat{x}^{i}[k]=\begin{cases}A_{0},&y^{i}[k]<t^{i}\\ A_{1},&y^{i}[k]<t^{i}\end{cases} \tag{7}\]  
which can be directly demodulated into bits. The second detection technique relies on an ad hoc computation of log-likelihood ratios (LLRs) for each bit. As we assume that no prior knowledge about the statistics of the channel exists, we compute estimates for the  
Figure 2: Type of pulses.  
probabilities \(p_{1,k}=P(x^{i}[k]=A_{1}|y^{i})\) and \(p_{0,k}=P(x^{i}[k]=A_{0}|y^{i})\) considering a uniform distribution whose bounds are defined by \(y^{i}_{min}\) and \(y^{i}_{max}\). In this case, these probabilities are obtained as  
\[p_{1,k}=\frac{y^{i}[k]-y^{i}_{min}}{y^{i}_{max}-y^{i}_{min}} \tag{8}\]  
and  
\[p_{0,k}=\frac{y^{i}_{max}-y^{i}[k]}{y^{i}_{max}-y^{i}_{min}}. \tag{9}\]  
Soft values can then be computed as the conditional expected value of the symbols which can be written as  
\[\hat{x}^{i}[k]=E(x^{i}[k]\big{|}y^{i})=(A_{1}-A_{0})p_{1,k}+A_{0}. \tag{10}\]  
Taking into account that the LLRs for the individual bits can be expressed as  
\[\lambda^{i}[k]=log\bigg{(}\frac{p_{1,k}}{p_{0,k}}\bigg{)} \tag{11}\]  
we can write  
\[p_{1,k}=\frac{1}{1+e^{-\lambda^{i}[k]}} \tag{12}\]  
which allows us to compute the soft-values as  
\[\hat{x}^{i}[k]=\frac{(A_{1}-A_{0})}{1+e^{-\lambda^{i}[k]}}+A_{0}. \tag{13}\]  
Note that in the case of OOK, with \(x^{i}[k]\in\{0,A\}\), this expression can be rewritten as  
\[\hat{x}^{i}[k]=\frac{A}{2}\bigg{(}\tanh\bigg{(}\frac{\lambda^{i}[k]}{2}\bigg{)} +1\bigg{)}. \tag{14}\]  
In the case of a polar modulation, where \(x^{i}[k]\in\{-A,A\}\), (13) reduces to  
\[\hat{x}^{i}[k]=A\bigg{(}\tanh\bigg{(}\frac{\lambda^{i}[k]}{2}\bigg{)}\bigg{)}. \tag{15}\]  
These soft estimates then allow simple soft-decision decoding based on squared Euclidean distance minimization.  
While the assumption of uniform distribution used for computing (8) and (9) can be considered empirical, the simulation results presented in Section 3.1 show that it is in fact reasonable as the performances of TCH codes with this type of detection clearly outperform not only the uncoded case but also the same TCH codes using the hard decision approach. Furthermore, note that all the derived expressions for the computation of the LLRs do not depend on the specific distribution assumed for probabilities (8) and (9), which means that if a different distribution was to be considered (for example, due to some channel knowledge acquired by the receiver) only the computations in (8) and (9) would become different.