You might find FastChebInterp easier for this. It can do Chebyshev regression from an arbitrary set of points to a given degree. (If you can evaluate at Chebyshev points it’s even better.). It’s lower level than ApproxFun, but that might be a plus here.
Of course, you have to think carefully about whether polynomials are a good fit here (pun intended), or if some specialized basis would be better for your problem, e.g. to capture the exponential tail. And of course you could also use polynomials after some change of variables or rescaling, or use more specialized polynomials like Gauss-Laguerre.
You could fit an LTI model directly using frequency-domain data, here are a number of methods implemented. I’d try subspaceid first. It sometimes requires some tweaking of the internal model order r to yield a good result. If you have time-domain data, you can of course use any other method from CSI as well.
Background information: I am currently looking at wind spectra. So there is no
simple dynamical system behind it, only mother earth…
They are usually characterized by the mean and the turbulence intensity. I want
to add one or more parameters to make it easier to compare different wind time
series in the frequency domain.
You can find some more info about this topic for example here:
There is never a simple linear system behind anything in practice, yet we use linear models to great effect all over the place
The spectrum you show does not look very complicated, in fact, it looks like the frequency response of a low order linear system, so I’d imagine that white noise filtered through a linear system could produce a very similar spectrum. Whether or not that would be useful is another question, maybe not, but if you had a parametric model of a linear system that matches your data, you’d have an easy way to get the desired bandwidths.
You may want to discard the frequencies below 0.001 , then a polynom of 3th or 4th order could be sufficient, at least for your purposes. But sure, it is better to have some idea of a physical model to fit.
I added root finding with Roots.jl and now I also get the -3db and -10db frequencies calculated:
Main weakness of this approach is that I do not get error margins for the result…
If I need that, I might try one of the many other approaches suggested in this thread.
It would probably be possible to augment FastChebInterp to give error bars from chebregression, since it’s just a least-square fit in a particular basis.
Agreed, or at least below .0001 that flat region isn’t telling you anything much but to make a polynomial stay flat for a long distance would require more terms.