Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python version of Matlab Signal Toolbox's tfestimate()? [closed]

Is there a Python version of Matlab's tfestimate()? I have looked into the control toolbox but it only offers linear transfer functions.

like image 312
The Guy Avatar asked Feb 11 '15 18:02

The Guy


People also ask

What can I do with MATLAB toolbox and MATLAB scripts?

Both apps generate MATLAB ® scripts to reproduce or automate your work. Using toolbox functions, you can prepare signal datasets for AI model training by engineering features that reduce dimensionality and improve the quality of signals. You can access and process collections of files and large datasets using signal datastores.

How to calculate the transfer function in tfestimate?

10 As shown in the 'more about' section of the help of tfestimate, the transfer function is calculated more or less as Txy = Pyx / Pxx, so by dividing the cross-spectral-density between yand xby the power-spectral-density of x.

What is signal labeling toolbox?

With the Signal Labeler app, you can annotate signal attributes, regions, and points of interest to create labeled signal sets. The toolbox supports GPU acceleration in addition to C/C++ and CUDA ® code generation for desktop prototyping and embedded system deployment. What Is Signal Processing Toolbox?. Video length is 1:46.

How do I call Python modules in MATLAB®?

To call Python ® modules in MATLAB ®, you must have a supported version of the reference implementation (CPython) installed on your system. MATLAB supports versions 2.7, 3.7, and 3.8. For more information, see Versions of Python Compatible with MATLAB Products by Release. If you are on a Linux ® or Mac platform, you already have Python installed.


1 Answers

As shown in the 'more about' section of the help of tfestimate, the transfer function is calculated more or less as Txy = Pyx / Pxx, so by dividing the cross-spectral-density between y and x by the power-spectral-density of x. Note that for calculating the cross-spectral density, the order of the arguments is important, since Pyx is calculated (after appropriate windowing and normalization) as the average of fft(y) * conj(fft(x)) over the individual windows. Similarly, the PSD Pxx is calculated as averaging fft(x) * conj(fft(x)). I forgot exactly why, but there is a good reason why you calculate it as the ratio between these two averages, instead of directly averaging fft(y) / fft(x).

Both cpsd and psd are available in matplotlib.mlab, so you can calculate a transfer function more or less like this (untested):

from matplotlib.mlab import psd, csd

def tfe(x, y, *args, **kwargs):
   """estimate transfer function from x to y, see csd for calling convention"""
   return csd(y, x, *args, **kwargs) / psd(x, *args, **kwargs)
like image 78
Bas Swinckels Avatar answered Nov 15 '22 08:11

Bas Swinckels