# Dynamical system identification - the julian way?

**URL:** <https://discourse.julialang.org/t/dynamical-system-identification-the-julian-way/79148>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [April 7, 2022, 8:08am UTC](https://discourse.julialang.org/t/dynamical-system-identification-the-julian-way/79148 "2022-04-07T08:08:17Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![BambOoxX](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bambooxx/32/22179_2.png) [@BambOoxX](https://discourse.julialang.org/u/BambOoxX)\
**Post date:** [April 7, 2022, 8:08am UTC](https://discourse.julialang.org/t/dynamical-system-identification-the-julian-way/79148/1 "2022-04-07T08:08:17Z")

</div>

Hello all !

I’m working on a structural dynamics identification topic involving the identification of a model coefficients for frequency response functions (or transfer function if your prefer).

The model is the following  
H(\omega) = \sum\_{m = 1}^{n\_m} \left(\frac{R\_m}{\mathrm{i}\omega-\lambda\_m}+\frac{\bar R\_m}{\mathrm{i}\omega-\bar\lambda\_m}\right) - \frac{R\_\mathrm{L}}{\omega^2} + R\_\mathrm{U}  
where H(\omega) \in \mathbb{C}^{n\_o\times n\_i} contains the values of all input-output pairs at one frequency, R\_m \in \mathbb{C}^{n\_o\times n\_i} are the so-called residuals.

Standard (for structural system identification) strategies exist to tackle this kind of problem, but I was wondering how I could use julia’s qualities especially in terms of the ML ecosystem to identify such a model.

Thanks for any help !

---

<div class="post-metadata">

**Author:** ![goerch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerch/32/29122_2.png) [@goerch](https://discourse.julialang.org/u/goerch)\
**Post date:** [April 7, 2022, 9:21am UTC](https://discourse.julialang.org/t/dynamical-system-identification-the-julian-way/79148/2 "2022-04-07T09:21:03Z")

</div>

We probably have to wait for someone like @baggepinnen who has an idea what you are talking about;)

My only idea is [https://github.com/JuliaControl/ControlSystems.jl/](https://github.com/JuliaControl/ControlSystems.jl/) could be related.

---

<div class="post-metadata">

**Author:** ![zdenek\_hurak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zdenek_hurak/32/53118_2.png) [@zdenek\_hurak](https://discourse.julialang.org/u/zdenek_hurak)\
**Post date:** [April 7, 2022, 9:31am UTC](https://discourse.julialang.org/t/dynamical-system-identification-the-julian-way/79148/3 "2022-04-07T09:31:26Z")

</div>

[https://github.com/baggepinnen/ControlSystemIdentification.jl](https://github.com/baggepinnen/ControlSystemIdentification.jl)

---

<div class="post-metadata">

**Author:** ![BambOoxX](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bambooxx/32/22179_2.png) [@BambOoxX](https://discourse.julialang.org/u/BambOoxX)\
**Post date:** [April 7, 2022, 10:26am UTC](https://discourse.julialang.org/t/dynamical-system-identification-the-julian-way/79148/4 "2022-04-07T10:26:32Z")

</div>

@goerch @zdenek_hurak , I too saw that @baggepinnen is working on closely related topics. Unfortunately the `tfest` functionnality in `ControlSystemIdentification` does not seem to support Multiple Input - Multiple Output (MIMO) systems.

I also found [Home · DataDrivenDiffEq.jl](https://datadriven.sciml.ai/stable/), but I don’t think it is applicable to frequency domain data.

The main issue with this kind of problem is that the \lambda\_m in the denominators also are to be estimated requiring a nonlinear resolution process.

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [April 7, 2022, 11:28am UTC](https://discourse.julialang.org/t/dynamical-system-identification-the-julian-way/79148/5 "2022-04-07T11:28:09Z")

</div>

Do you have frequency domain or time domain data? The function  
[https://baggepinnen.github.io/ControlSystemIdentification.jl/dev/ss/#ControlSystemIdentification.subspaceid](https://baggepinnen.github.io/ControlSystemIdentification.jl/dev/ss/#ControlSystemIdentification.subspaceid)  
supports both, and estimates a state-space model which you may later convert to a transfer function using `tf(model)`

---

<div class="post-metadata">

**Author:** ![BambOoxX](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bambooxx/32/22179_2.png) [@BambOoxX](https://discourse.julialang.org/u/BambOoxX)\
**Post date:** [April 7, 2022, 11:47am UTC](https://discourse.julialang.org/t/dynamical-system-identification-the-julian-way/79148/6 "2022-04-07T11:47:53Z")

</div>

I have frequency domain data of a MIMO system as a matrix.

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [April 7, 2022, 11:53am UTC](https://discourse.julialang.org/t/dynamical-system-identification-the-julian-way/79148/7 "2022-04-07T11:53:13Z")

</div>

Then I suggest trying `subspaceid` where you package your data in a frequency-response data object [`FRD`](https://baggepinnen.github.io/ControlSystemIdentification.jl/dev/api/#ControlSystemIdentification.FRD). This functionality is fairly new, and there is not yet a fully worked example in the documentation. The link above leads to the docstring that (if you scroll down a bit) contains the method that works on frequency-domain data. If the documentation is insufficient, I’d be happy to hear what trips you up and I’ll try to improve it. You may also look on [how it’s used in the tests](https://github.com/baggepinnen/ControlSystemIdentification.jl/blob/master/test/test_subspace.jl#L329)

---

<div class="post-metadata">

**Author:** ![BambOoxX](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bambooxx/32/22179_2.png) [@BambOoxX](https://discourse.julialang.org/u/BambOoxX)\
**Post date:** [April 7, 2022, 11:56am UTC](https://discourse.julialang.org/t/dynamical-system-identification-the-julian-way/79148/8 "2022-04-07T11:56:24Z")

</div>

Thanks, I’ll try that ASAP and come back to you with some feedback !  
Still I’m wondering if more ML-advertised strategies could be leverage, such as [Parameter Estimation and Bayesian Analysis · DifferentialEquations.jl](https://diffeq.sciml.ai/stable/analysis/parameter_estimation/)

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [April 7, 2022, 11:59am UTC](https://discourse.julialang.org/t/dynamical-system-identification-the-julian-way/79148/9 "2022-04-07T11:59:10Z")

</div>

The model you proposed appears linear in the parameters and I see no reason to use anything complicated to estimate it. In general, frequency-domain methods are significantly less attractive for nonlinear systems since the simple frequency response is then no longer a complete characterization of the system, the frequency response for nonlinear systems will in general depend on both amplitude and history.

---

<div class="post-metadata">

**Author:** ![BambOoxX](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bambooxx/32/22179_2.png) [@BambOoxX](https://discourse.julialang.org/u/BambOoxX)\
**Post date:** [April 7, 2022, 12:02pm UTC](https://discourse.julialang.org/t/dynamical-system-identification-the-julian-way/79148/10 "2022-04-07T12:02:17Z")

</div>

The estimation is not linear since the \lambda\_m (in the denominators) are also to be estimated.

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [April 7, 2022, 12:05pm UTC](https://discourse.julialang.org/t/dynamical-system-identification-the-julian-way/79148/11 "2022-04-07T12:05:21Z")

</div>

The parametrization you use is not linear in the parameters, but it represents a linear system for which there are efficient estimation methods. Those methods, (like `subpsaceid`) estimate the model on another, equivalent form, and you can calculate the parameters in your model from the model that was identified. It requires you to calculate the residues of a rational function, Polynomials.jl contains a function for that.

---

<div class="post-metadata">

**Author:** ![BambOoxX](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bambooxx/32/22179_2.png) [@BambOoxX](https://discourse.julialang.org/u/BambOoxX)\
**Post date:** [April 7, 2022, 12:17pm UTC](https://discourse.julialang.org/t/dynamical-system-identification-the-julian-way/79148/12 "2022-04-07T12:17:33Z")

</div>

Yes, it represents a LTI system indeed. I actually use some specialized methods myself (not subspace identification though).  
One of the difficulties in my case is that I may work on large MIMO systems which make some resolutions troublesome.  
I’m using functionalities in `Polynomials` or `SpecialPolynomials` to find the poles of some matrix-valued polynomials, but AFAIK there is no implementation specialized for rational functions.  
One other potentially helpful link is [https://github.com/tomasmckelvey/fsid](https://github.com/tomasmckelvey/fsid)

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [April 7, 2022, 12:21pm UTC](https://discourse.julialang.org/t/dynamical-system-identification-the-julian-way/79148/13 "2022-04-07T12:21:18Z")

</div>

Have a look at  
[https://github.com/JuliaMath/Polynomials.jl/blob/v3.0.0/src/rational-functions/common.jl#L581](https://github.com/JuliaMath/Polynomials.jl/blob/v3.0.0/src/rational-functions/common.jl#L581)  
and also [Home · DescriptorSystems.jl](https://andreasvarga.github.io/DescriptorSystems.jl/dev/) (not estimation, but manipulation and analysis of rational models)

---

<div class="post-metadata">

**Author:** ![A\_C](https://avatars.discourse-cdn.com/v4/letter/a/da6949/32.png) [@A\_C](https://discourse.julialang.org/u/A_C)\
**Post date:** [April 7, 2022, 1:22pm UTC](https://discourse.julialang.org/t/dynamical-system-identification-the-julian-way/79148/14 "2022-04-07T13:22:46Z")

</div>

Generally subspace identification requires time domain data. How is it done if frequency domain data is available?

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [April 7, 2022, 1:51pm UTC](https://discourse.julialang.org/t/dynamical-system-identification-the-julian-way/79148/15 "2022-04-07T13:51:46Z")

</div>

You can use subspace methods in the frequency domain as well, there are several papers investigating this, e.g., by the above reference author Tomas McKelvey

---

<div class="post-metadata">

**Author:** ![A\_C](https://avatars.discourse-cdn.com/v4/letter/a/da6949/32.png) [@A\_C](https://discourse.julialang.org/u/A_C)\
**Post date:** [April 7, 2022, 2:19pm UTC](https://discourse.julialang.org/t/dynamical-system-identification-the-julian-way/79148/16 "2022-04-07T14:19:43Z")

</div>

Thanks for the reference.
