# Cross-Entropy Method in Application to the SIRC Model
## Appendix A Optimization by the Method of Cross-Entropy
### Minimization of Mean Sum of Ranks  
Let's consider the following problem of minimizing the mean sum of ranks:  
\[\min_{x\in\chi}\operatorname{\mathsf{E}}(x,R), \tag{12}\]  
where \(\chi=\{x=(x^{(1)},\ldots,x^{(k)}):\text{conditions from \eqref{eq:11} are preserved}\}\) is some defined set. \(R=(R_{1},\ldots,R_{N})\) is a random permutation of numbers \(1,\ldots,N\). \(\hat{S}\) is an unbiased estimator \(\operatorname{\mathsf{E}}(x,R)\) with the following formula:  
\[\hat{S}(x)=\frac{1}{N_{1}}\sum_{n=1}^{N_{1}}(R_{n\tau_{1}}+\cdots+R_{n\tau_{k} }),\]  
where \((R_{n1},\ldots,R_{nN})\) is the nth copy of a random permutation \(R\). Now, a cross-entropy algorithm can be applied (v. Section 1.3 and [5]). Let's define the indicator collections \(\{l_{\{S(x)\leqslant\gamma\}}\}\) on \(\chi\) for different levels \(\gamma\in R\). Let \(\{f((\cdot\,;u)\}\) be the density family on \(\chi\) parameterized by the actual parameter value \(u\). For a specific \(u\) we can combine (12) with the problem of estimation  
\[l(\gamma)=\operatorname{\mathbf{P}}_{u}(S(X)\leqslant\gamma)=\sum_{x}l_{\{S( x)\leqslant\gamma\}}f(x,u)=\operatorname{\mathbf{E}}_{u}l_{\{S(x)\leqslant \gamma\}},\]  
where \(\operatorname{\mathbf{P}}_{u}\) is a measure of the probability in which the random state \(X\) has a density \(\{f((\cdot\,;u)\}\) and \(\gamma\) is a known or unknown parameter. \(l\) we estimate using the Kullback-Leibler distance. The Kullback-Leibler distance is defined as follows:  
\[D(g,h)=\int g(x)\ln g(x)dx-\int g(x)h(x)dx.\]  
Usually \(g(x)\) is chosen from the family of density \(f(\cdot\,;v)\). So here \(D\) for \(g\) and \(f(x;v)\) it comes down to selecting such a reference parameter \(v\) for which \(-\int g(x)\ln f(x;v)dx\) is the smallest, that is, it comes down to maximization:  
\[\max_{v}\int g(x)f(x;v)dx.\]After some transformations:  
\[\max_{v}D(v)=\max_{v}\frac{1}{N}\sum_{i=1}^{N}\mathbb{I}_{\{S(X_{i})\geq\gamma\}} W(X_{i};u;w)\ln f(X_{i};v).\]  
So firstly, let us generate a pair \(\{(\gamma_{t},u_{t})\}\), which we then update until the stopping criterion is met and the optimal pair is obtained \(\{(\gamma^{*},u^{*})\}\). More precisely, arrange \(u_{0}\) and choose not too small \(\rho\) and we proceed as follows:  
**(1) Updating \(\gamma_{t}\)**: Generate a sample \(X_{1},\ldots,X_{N_{2}}\) from \(\{f((\cdot;u_{t-1})\}\). Calculate \(\hat{S}(X_{1}),\ldots,\hat{S}(X_{N_{2}})\) and sort in ascending order. For \(\hat{\gamma}_{t}\) choose  
\[\hat{\gamma}_{t}=\hat{S}_{([eN])}\]
**(2) Updating \(u_{t}\)**: \(\hat{u}_{t}\) obtain from the Kullback-Leibler distance, that is, from maximization  
\[\max_{u}D(u)=\max_{u}\mathbf{E}_{u_{t-1}}I_{\{S(x)\leq\gamma_{t}\}}Inf(X;u),\] (A3)  
so  
\[\max_{u}\hat{D}(u)=\max_{u}\frac{1}{N_{2}}\sum_{n=1}^{N_{2}}I_{\{S(x)\leq\hat{ \gamma}_{t}\}}Inf(X_{n};u).\] (A4)  
As in [49], here a three-dimensional matrix of parameters \(u=\{u_{ijl}\}\) is consider. \[u_{ijl}=\Pr\{X_{j}^{(i)}=l\},\;i=1,\ldots,k;\quad j=k-i+1,\ldots,N-i;l=0, \ldots,N-1.\]  
It seems that  
\[\hat{S}(x)=\frac{1}{N_{1}}\sum_{n=1}^{N_{1}}(R_{n\tau_{1}}+\cdots+R_{n\tau_{k} }),\]0  
and then after some transformations  
\[\hat{S}(x)=\frac{1}{N_{1}}\sum_{n=1}^{N_{1}}(R_{n\tau_{1}}+\cdots+R_{n\tau_{k} }),\]1 \[\hat{S}(x)=\frac{1}{N_{1}}\sum_{n=1}^{N_{1}}(R_{n\tau_{1}}+\cdots+R_{n\tau_{k} }),\]2  
where \(X_{n}=\{X_{nij}\}\), \(X_{nij}\) is a random variable from \(f(x_{j}^{(i)};\hat{u}_{t-1})\), corresponding to the Formula (A4). Instead of updating a parameter use the following smoothed version  
\[\hat{S}(x)=\frac{1}{N_{1}}\sum_{n=1}^{N_{1}}(R_{n\tau_{1}}+\cdots+R_{n\tau_{k} }),\]3
**(3) Stopping Criterion**: The criterion is from [16], which stop the algorithm when \(\hat{\gamma}_{T}\) (\(T\) is last step) has reached stationarity. To identify the stopping point of \(T\), consider the following moving average process  
\[\hat{S}(x)=\frac{1}{N_{1}}\sum_{n=1}^{N_{1}}(R_{n\tau_{1}}+\cdots+R_{n\tau_{k} }),\]4  
where \(K\) is fixed.