# Synchronization, Control and Data Assimilation of the Lorenz System
## 4 Pruned-Enriching Approach
```
\(\{\mathbf{w}_{n}\},\delta,\mathbf{Q}^{(i)},dt,\tau,M,T_{0}\) \(m\gets 0\) for\(m<M\)do \(t\gets 0\) \(\mathbf{R}_{0}^{(i)}\leftarrow\) random in \([a,b]\) \(\mathbf{W}\leftarrow\) Ensemble evolution up to \(t=T_{0}\) and store measure every \(\tau\) for\(t<T\)do if\(t\propto\tau\)then \(\mathbf{W}\leftarrow\) Update with \(f(\mathbf{R})\) \(d\leftarrow\) Euclidean distance \(d(w_{n},\mathbf{W}_{n})\) \(\mathbf{Q}\leftarrow\) Parameter updating step \(\triangleright\) Algorithm 2 \(\mathbf{Q}\leftarrow\) Mean of first \(R/2\) ensemble elements endif \(\mathbf{R}\leftarrow\) Evolution step with time step \(dt\) and \(\mathbf{Q}\) as parameters \(t\gets t+dt\) endfor endfor return\(\tilde{\mathbf{Q}}\)
```  
**Algorithm 1** Pruned-enriching algorithm  
```
\(R,\delta,d,\mathbf{W},\mathbf{w}(t)\) \(\text{index}\leftarrow\text{argsort(d)}\)\(\triangleright\) return index of d sorted in ascending order for\(i\) in \(\text{range}(R/2,R)\)do \(\mathbf{Q}_{i}\leftarrow\mathbf{Q}_{j}\) with \(j\) random integer in \((0,R/2)\) if\(\text{random}(0,1)<0.5\)then \(k\leftarrow\) random integer in \((1,2,3)\) \(\mathbf{Q}_{ik}\leftarrow\mathbf{Q}_{jk}+\text{random}(-\delta,\delta)\) while\(\mathbf{Q}_{ik}<0\)do \(\mathbf{Q}_{ik}\leftarrow\mathbf{Q}_{jk}+\text{random}(0,\delta)\) endwhile else \(\mathbf{R}_{ik}\leftarrow\mathbf{R}_{jk}+\text{random}(-\delta,\delta)\) endif endfor return\(\mathbf{Q}\)
```  
**Algorithm 2** Parameter updating step  
To create the initial embedding vectors \(\mathbf{W}_{n}^{(i)}\big{(}f(\mathbf{R}_{n}^{(i)}),f(\mathbf{R}_{n-1}^{(i)}),\ldots,f(\mathbf{R}_ {n-d_{e}+1}^{(i)})\big{)}\), \(n=d_{e}\), we evolve the replica ensemble for a time interval \(T_{0}=d_{e}\tau\) so that for each replica we can build the first \(d_{e}\) elements of their time series. We can then start the optimization procedure. For a number of repetitions \(M\), we evolve the ensemble using a time step \(\text{d}t\), up to time \(t=T\). At each interval \(n\tau\), we update the embedding vector \(\mathbf{W}_{n}^{(i)}\), substituting the oldest measurements with the new ones and computing the Euclidean distances \(d^{(i)}\) between the \(\mathbf{W}_{n}^{(i)}\) and the reference \(\mathbf{w}_{n}\) computed on the master system. Notice that, for \(M>1\), we rescan the time series from the beginning, reinitializing the random conditions of the replicas as in the first repetition but without changing their parameters, and we recompute the initial vector \(\mathbf{W}_{n}^{(i)}\), \(n=d_{e}\), evolving the ensemble members up to time \(t=T_{0}\). The distance \(d^{(i)}\) is used as the cost function of our optimization problem. In the parameter updating step (Algorithm 2), we sort the elements of the set in ascending order according to \(d^{(i)}\) and replace the second half of the set with a copy of the first half, with either a random perturbation of amplitude \(\delta\) in one of the parameters or a random perturbation of the state variables; see Algorithm 2. We add some checks in order to be sure that the values of parameters are not inconsistent (in our case, all the \(\mathbf{Q}^{(i)}\) need to be positive). After that, we compute \(\tilde{\mathbf{Q}}\), the estimated parameters, as the average of the first half of the ensemble elements with an associated ensemble error. Because this procedure depends on the extraction of random numbers, it can then be repeated to estimate the consequent statistical error on parameters. We analyze the convergence problem for different values of \(\delta\). We assume that only the \(x\) component of the real system is accessed, i.e., our measurement function is simply \(f(\mathbf{r})=x\). We evolve the system up to \(T=100\) with the time step \(dt=0.01\), and we measure every \(\tau=0.2\). We embed the system in a embedding space of dimensions \(d_{e}=5\). The ensemble is composed of \(h=10\),\(000\) replicas, and we repeat the procedure for \(M=5\) times.