{'fraction_non_alphanumeric': 0.03919765252047475, 'fraction_numerical': 0.012219156484036263, 'mean_word_length': 4.051769911504425, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 9, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Identifying the Dynamics of a System by Leveraging Data from Similar Systems

We study the problem of identifying the dynamics of a linear system when one has access to samples generated by a similar (but not identical) system, in addition to data from the true system. We use a weighted least squares approach and provide finite sample performance guarantees on the quality of the identified dynamics. Our results show that one can effectively use the auxiliary data generated by the similar system to reduce the estimation error due to the process noise, at the cost of adding a portion of error that is due to intrinsic differences in the models of the true and auxiliary systems. We also provide numerical experiments to validate our theoretical results. Our analysis can be applied to a variety of important settings. For example, if the system dynamics change at some point in time (e.g., due to a fault), how should one leverage data from the prior system in order to learn the dynamics of the new system? As another example, if there is abundant data available from a simulated (but imperfect) model of the true system, how should one weight that data compared to the real data from the system? Our analysis provides insights into the answers to these questions.


I. INTRODUCTION
The problem of dynamical system identification has been an important topic in various fields including economics, control theory and reinforcement learning [1]. When modeling from first principles is not possible, one can attempt to learn a predictive model from observed data. While classical system identification techniques focused primarily on achieving asymptotic consistency [2]- [4], recent efforts have sought to characterize the number of samples needed to achieve a desired level of accuracy in the learned model.
The existing literature on finite sample analysis of system identification can be typically divided into two categories: single trajectory-based and multiple trajectories-based. In the single trajectory setup, it is assumed that one has access to a single long record of system input/output data, e.g., [5]- [10]. This approach enables system identification without restarting the experiment multiple times. In contrast, for the multiple trajectories setup, it is typically assumed that one has access to multiple independent (short) trajectories of the system, e.g., [11]- [15]. Due to the assumption of independence over multiple trajectories, standard concentration inequalities usually apply in this case. In practice, one may obtain multiple trajectories of the system if one can restart the experiment, or if the data are generated from identical systems running in parallel.
We note that all of the above works assume that the data used for system identification are generated from the true system model that one wants to learn. However, in many cases, collecting abundant data from the true system can be costly or infeasible, and one may want to rely on data generated from similar systems. For example, for nonengineered systems like animals, one may only have a limited amount of data from the true animal one wants to model, due to the challenge of conducting experiments. On the other hand, it may be possible to collect data from other animals in the herd or from a reasonably good simulator, and one may want to leverage these available data. Furthermore, when a system changes its dynamics (e.g., due to failures), one needs to decide whether to discard all of the previous data, or to leverage the old information in an appropriate way. In settings such as the ones described above, it is of great interest to determine how one can leverage the data generated from systems that share similar (but not identical) dynamics. This idea is similar to the notion of transfer learning in machine learning, where one wants to transfer knowledge from similar tasks to a new task [16]. However, in contrast to system identification, most of the papers on transfer learning consider learning a static mapping from a feature space to a label space [17].
In this paper, we study the system identification problem using both data generated from the true system that one wants to identify and data generated from an auxiliary (potentially time-varying) system that shares similar dynamics. Similarly to [11], we consider the multiple trajectories setup. However, unlike [11], we use all samples instead of only the last one from each trajectory in order to improve data efficiency. We use a weighted least squares approach and provide a finite sample upper bound on the estimation error. Our result shows that one can leverage the auxiliary data to reduce the error due to the noise, at the cost of adding a bias that depends on the difference between the true and auxiliary systems. We also provide simulations to validate our theoretical results, and to provide insights into various settings (including the example scenarios discussed above).

II. MATHEMATICAL NOTATION AND TERMINOLOGY
Let R denote the set of real numbers. Let λ min (·) and λ max (·) be the smallest and largest eigenvalues, respectively, of a symmetric matrix. We use * to denote the conjugate transpose of a given matrix. We use · and · F to denote the spectral norm and Frobenius norm of a given matrix, respectively. Vectors are treated as column vectors. A Gaussian distributed random vector is denoted as u ∼ N (µ, Σ), where µ is the mean and Σ is the covariance matrix. We use I n to denote the identity matrix with dimension n × n.

III. PROBLEM FORMULATION AND ALGORITHM
Consider a discrete time linear time-invariant (LTI) system wherex k ∈ R n ,ū k ∈ R p ,w k ∈ R n , are the state, input, and process noise, respectively, andĀ ∈ R n×n andB ∈ R n×p are system matrices. The input and process noise are assumed to be i.i.d Gaussian, withū k ∼ N (0, σ 2 u I p ) and w k ∼ N (0, σ 2 w I n ). Note that Gaussian inputs are commonly used in system identification, e.g., [11], [14]. We also assume that both the inputū k and statex k can be perfectly measured.
Suppose that we have access to N r independent experiments of system (1), in which the system restarts from an initial statex 0 ∼ N (0, σ 2 x I n ), and each experiment is of length T . We call the state-input pairs collected from each experiment a rollout, and denote the set of samples we have as where the superscript denotes the rollout index and the subscript denotes the time index.
In general, one would like to solve: and obtain an estimate Θ LS Ā LSBLS , of which the analytical form is assuming invertibility of the matrixZZ * . However, without enough samples (i.e., if N r is small, and there is no single long run record available), the obtained estimate could have large estimation error. In such cases, we can rely on samples generated from an auxiliary system, if it shares "similar" dynamics to system (1). In particular, consider an auxiliary discrete time linear time-varying system wherex k ∈ R n ,û k ∈ R p ,ŵ k ∈ R n are the state, input, and process noise, respectively, andÂ k ∈ R n×n andB k ∈ R n×p are system matrices. Again, the input and process noise are assumed to be i.i.d Gaussian, withû k ∼ N (0, σ 2 u I p ) and w k ∼ N (0, σ 2 w I n ). Note that an LTI system is a special case of the above system, withÂ k =Â andB k =B for all k ≥ 0. The dynamics of system (5) can be rewritten aŝ where Intuitively, the samples generated from the above system will be useful for identifying system (1) if δ A k , δ B k are small for all k. Now, suppose that we also have access to N p independent experiments of system (5), in which the system restarts from an initial statex 0 ∼ N (0, σ 2 x ), and each experiment is of for k ≥ 2, withĜ 1 = 0 andF 1 = 0. For k ≥ 2. we havê for all i ∈ {1, . . . , N p }, and denoting we have the relationship Letting q k ∈ R ≥0 be a design parameter that specifies the relative weight assigned to samples generated from the auxiliary system (5) at time step k, we can We are interested in the following weighted least squares problem: The well known weighted least squares estimate is Θ W LS Ā W LSBW LS , which has the form when the matrix ZQZ * is invertible. Using (10), the estimation error can be expressed as The above steps are encapsulated in Algorithm 1.
Algorithm 1 System Identification Using Auxiliary Data 1: Gather N r length T rollouts of samples generated from the true system (1), Remark 1: Note that the weight parameter q k specifies how much we should weight the data from the auxiliary system relative to the data from the true system, and can be a function of the number of rollouts (N r and N p ) from each of those systems. Our analysis in the next section, and subsequent evaluation, will provide guidance on the appropriate choice of weight parameter.
Next, we provide upper bounds on the estimation error Θ W LS − Θ as a function of N r , N p , δ Θ k , q k and other system parameters. Moreover, we will provide insights into the case when the auxiliary system is time-invariant.

IV. ANALYSIS OF THE SYSTEM IDENTIFICATION ERROR
To upper bound the estimation error in (13), we will upper bound the error terms W QZ , (ZQZ * ) −1 , and ∆QZ * separately. We will start with some intermediate results pertaining to these quantities.

A. Intermediate Results
We will rely on the following lemma from [18, Corollary 5.35], which provides non-asymptotic lower bound and upper bound of a standard Wishart matrix. Lemma 1: Let u i ∼ N (0, I n+p ), i = 1, . . . , N be i.i.d random vectors. For any fixed δ > 0, with probability at least 1 − δ, we have the following inequalities: We have the following results.
δ . With probability at least 1 − δ, we have the following inequalities: Proof: We havê For any fixed k, defineû i k =Σ Similarly, we have Fixing δ > 0 and k and applying Lemma 1, we have with probability at least 1 − δ T the following: Further, we have Noting the inequality 2(a 2 + b 2 ) ≥ (a + b) 2 , we can write Letting N p ≥ 8(n + p) + 16 log 2T δ , one can then show that the following inequalities hold with probability at least 1− δ T : It follows that with probability at least 1 − δ T , The result follows by applying a union bound for all k in (14) and (15), Proposition 2: Fixing δ > 0, and letting N r ≥ N 0 = 8(n + p) + 16 log 2T δ , we have with probability at least 1 − δ, Proof: Replacing q k by 1, the proof follows directly from Proposition 1.
Next, We will leverage the following lemma from [11, Lemma 1] to bound the contribution from the noise terms.
Lemma 2: Let f i ∈ R m , g i ∈ R n be independent random vectors f i ∼ N (0, Σ f ) and g i ∼ N (0, Σ g ), for i = 1, · · · , N . Let N ≥ 2(n + m) log 1 δ . For any fixed δ > 0, we have with probability at least 1 − δ, We have the following results. Proposition 3: For any fixed δ > 0, let N p ≥ N 1 (4n+ 2p) log T δ . We have with probability at least 1 − δ Proof: From the definitions ofŴ ,Q andẐ, (16) Fix δ > 0, and let N p ≥ (4n + 2p) log T δ . For any fixed k, we can apply Lemma 2 to obtain that with probability at Further applying a union bound for all k in (16), we get the desired result. Proposition 4: For any fixed δ > 0, let N r ≥ N 1 = (4n+ 2p) log T δ . We have with probability at least 1 − δ, Proof: Replacing q k by 1, the proof follows directly from Proposition 3.

B. Main Results and Insights
We now come to the main result of our paper, providing a bound on the system identification error in (13).

Proof:
Recall that the estimation error in (13) First, note that ZQZ * =ZZ * + ZQẐ * . Fixing δ > 0, letting min (N r , N p ) ≥ N 0 , combining Proposition 2 and the lower bound in Proposition 1 using a union bound, and taking the inverse, we obtain that with probability at least 1 − 2δ, .
(17) Similarly, note that W QZ * =WZ * +ŴQẐ * . Letting min (N r , N p ) ≥ N 1 , and combining Proposition 4 and Proposition 3 using a union bound, we obtain that with probability at least 1 − 2δ, Finally, combining (17) Note that the first term in the bound on the error corresponds to the error due to the noise from the two systems, and the second term corresponds to the error due to the intrinsic model difference. Now, we state a corollary of the above theorem when the auxiliary system is time-invariant, which helps us gain more insights into the above result.
Corollary 1: Suppose that the auxiliary system (5) is Let q k = q for all k ≥ 0 in problem (11). For any fixed δ > 0, let min (N r , N p ) ≥ max{N 0 , N 1 }, where N 0 = 8(n + p) + 16 log 2T δ , N 1 = (4n + 2p) log T δ . Then, with probability at least 1 − 4δ, the least squares solution to problem (11) satisfies Error due to difference between true and auxiliary systems , where c 0 = 16 (2n + p) log 9T δ Remark 2: Interpretation of Corollary 1 and the selection of weight parameter q. Recall that N r is the number of rollouts from the true system (1), and N p is the number of rollouts from the auxiliary system (5). From the upper bound in (19), one can observe that when q is fixed, increasing N p reduces the error due to the noise, at the cost of adding a bias that is due to the intrinsic model difference δ Θ . Choosing the optimal weight q in practice requires an oracle (to know the specific values of the different parameters in (19)), and one would leverage a cross-validation process to select a good q (see [19] for an overview). However, general guidelines can be given based on the upper bound provided by Corollary 1 when N p is large: • When N r is small, we can increase q to reduce the first term in the error bound (such that the error bound is dominated by the second term). This corresponds to the case where we have little data from the true system, and thus there may be a large identification error due to using only that data. In this case, it is worth placing more weight on the data from the auxiliary system, up to the point that the reduction in estimation error due to the larger amount of data is balanced out by the intrinsic differences between the systems. • When N r is large, we can decrease q to reduce the second term as well, since the first term is already small enough. This corresponds to the case where we have a large amount of data from the true system, and only need the data from the auxiliary system to slightly improve our estimates (due to the presence of additional data). In this case, we place a lower weight on the auxiliary data in order to avoid excessive bias due to the difference in dynamics. The above insights align well with intuition, and are supported by the mathematical analysis provided in this section. We also illustrate these ideas experimentally in Section V.
Finally, the following result provides a (sufficient) condition under which using the data from the auxiliary system leads to a smaller error bound (compared to using data only from the true system).
Corollary 2: Consider the upper bound provided in Corollary 1. Setting q to be non-zero will result in a smaller upper bound if Proof: When q = 0, from Corollary 1, we have .
From Weyl's inequality [20], we have The proof now follows by setting Remark 3: Interpretation of Corollary 2. We note that the above sufficient condition (20) could be conservative, and may not be directly checked in practice due to the unknown parameters. However, we describe the insights provided by this condition. In general, condition (20) is more likely to be satisfied if σŵ is small (the auxiliary system is less noisy), δ Θ is small (the true system and auxiliary system are very similar), or N p is large (one has a lot of samples from the auxiliary system), as this would make the right hand side of (20) smaller. In such cases, the auxiliary samples tend to be more informative. In contrast, condition (20) is less likely to be satisfied if σw is small and N r is large, i.e., when the data from the true system is not too noisy and one has a lot of samples from that system, the auxiliary samples tend to be less informative.

V. NUMERICAL EXPERIMENTS TO ILLUSTRATE VARIOUS SCENARIOS FOR SYSTEM IDENTIFICATION FROM AUXILIARY DATA
We now provide some numerical examples of the weighted least squares-based system identification algorithm (Algorithm 1), when the auxiliary system is LTI. The experiments are performed using the following system matrices: and σ 2 x , σ 2 x , σ 2 u , σ 2 u σ 2 w , σ 2 w are set to be 1. The rollout length is set to be T = 2 for all experiments in the sequel. All results are averaged over 10 independent runs.
A. Scenario 1: Both N r and N p are increasing For the first experiment, the number of rollouts from the auxiliary system is set to be N p = 3N r . In practice, one may encounter such a scenario when running experiments to gather data from the true system is time consuming or costly, whereas gathering data from an auxiliary system (such as a simulator) is easier or cheaper.
In Fig. 1, we plot the estimation error versus N r for different weight parameters q. As expected, setting q > 0 leads to a smaller estimation error of system matrices when one does not have enough data from the true system (small N r ). However, the curve for q = 1 and q = 10 10 (corresponding to treating all samples equally and paying almost no attention to the samples from the true system, respectively) eventually plateau and incur more error than not using the the auxiliary data (q = 0). This phenomenon matches the theoretical guarantee in Corollary 1. Specifically, when q is a nonzero constant, the upper bound in (19) will not go to zero as N r increases; furthermore, since both N p and N r are increasing in a linear relationship, there is no need to attach high importance to the auxiliary data when one has enough data from the true system. In contrast, setting q to be diminishing with N r could perform consistently better than q = 0, even when N r is large. Indeed, one can choose q = O( 1 √ Nr ) in the upper bound given by (19) in Corollary 1, and show that the upper bound becomes O( 1 √ Nr ). Thus, the estimation error tends to zero as N r increases to infinity.
Key Takeaway: When N p and N r are both increasing linearly, having q diminish with N r helps to reduce the system identification error when N r is small (by leveraging data from the auxiliary system), and avoids excessive bias from the auxiliary system when N r is large.
B. Scenario 2: N p is fixed but N r is increasing In the second experiment, we fix the number of rollouts from the auxiliary system to be N p = 2400, and study what happens as the number of rollouts from the true system increases. One may encounter such a scenario when the system dynamics change due to faults. In this case, the true system is the one after the fault, and the auxiliary system is the one prior to the fault. Consequently, the old data from the system (corresponding to the auxiliary system) may not accurately represent the new (true) system dynamics. While one can collect data from the new system dynamics, leveraging the old data might be beneficial in this case.
In Fig. 2, we plot the estimation error versus N r for different weight parameters q. As expected, setting q > 0 leads to a smaller error during the initial phase when N r is small. This can be confirmed by Corollary 1 since the error is essentially the error due to the model difference. Namely, the auxiliary data helps to build a good initial estimate. When we set the weight to be q = 10 10 , we are paying little attention to the samples from the true system, i.e., we are not gaining any new information as we collect more data from the true system. Consequently, the error is almost not changed as N r increases when q = 10 10 . As can be observed from Corollary 1, when N p is fixed, consistency can always be achieved as N r increases, using the weights we selected in the experiment. However, when q is set to be too large, it could make the error even larger due to the model difference (or bias) introduced by the auxiliary system. This is captured by Corollary 1 since when q is set to be large (such that qN p is large compared to N r ), even when N r gets large, the upper bound in (19) is still large due to the effect from the second term in the bound (capturing model difference).
Key Takeaway: When N p is fixed and large, and N r increases over time, setting q to be nonzero builds a good initial estimate for the true system dynamics when N r is small. Again, having q diminish with N r helps to reduce the system identification error when N r is small, and avoids excessive bias from the auxiliary system when N r is large. In the last experiment, we fix the number of rollouts from the true system to be N r = 50. As discussed earlier, one may encounter such a scenario when one has only a limited amount of time to gather data from true system. As a result, leveraging information from other systems (e.g., from a reasonably accurate simulator) could be helpful to augment the data. This is the most subtle case, since N r is fixed and there is no way to guarantee consistency from Corollary 1.
In Fig. 3, we plot the the estimation error versus N p for different weight parameters q. As it can be seen, setting q = 0 (not using the auxiliary samples) gives a flat line, which is the error we can achieve purely based on N r = 50 rollouts from the true system. When q = 10 10 , we are essentially identifying the auxiliary system without caring about the true system. In contrast, the results for q = 1, 0.6, 0.3 suggest that setting a relatively balanced weight makes the error smaller than the two extreme cases (q = 0, 10 10 ). However, in practice, one may want to utilize a cross-validation process to select a good q, when there is not enough prior knowledge about the true system and the auxiliary system.
Key Takeaway: Although consistency cannot be guaranteed when N r is fixed and small, and N p increases over time, a relatively balanced q could make the error smaller than the extreme cases (q = 0, 10 10 ).

VI. CONCLUSION AND FUTURE WORK
In this paper, we provided a finite sample analysis of the weighted least squares approach to LTI system identification, when we have access to samples from an auxiliary system that shares similar dynamics. We showed that one can leverage the auxiliary data generated by the similar system to reduce the estimation error due to the noise, at the cost of adding a portion of error that is due to intrinsic differences in the models of the true and auxiliary systems. One limitation of our result is that our bound cannot capture the empirical trend that a longer length of rollout T (when we do not use samples from the auxiliary system) reduces the estimation error. One future direction is to develop a tighter bound by leveraging results from the single trajectory setup. In addition, it is also of interest to consider systems with special structures, such as sparsity.