# Get the inverse transfer function from the measured response

What is a numerically stable way to obtain the inverse transfer function from a measured response?

I have a system that shows a low-pass behavior. I would like to increase the bandwidth by some form of pre-emphasis. I have measured the response of the system to the shortest square pulse excitation I can do. This looks like this (pastebin):

I would like now to "pre-distort" my signal to amplify higher frequency components. How do I construct numerically (preferably Python or Matlab) an inverse filter that I use to generate the input signal such that I get a desired output of the system?

I am aware that this cannot go infinitely, but I hope to be able to extend the bandwidth by a factor of 1.5 to 2.

• What's your sample rate ? Your impulse response data isn't centered in time so providing a time axis for the date would help. The scaling doesn't match the picture either. Commented Mar 25, 2023 at 12:05

Extending the bandwidth by 1.5 or 2 is quite feasible depending on how tight the actual filtering is (for example with a simple first order roll-off, a 6 dB peaking properly placed will extend the bandwidth by two). I provide three different approaches for creating FIR filters to pre-emphasize for passband droop in bandwidth restricted channels: Using a least-squares equalizer when the stimulus can be modified to be either a sounding chirp or pseudo-random sequence, or determining the channel from the FFT of the OP's stimulus and response, or using a 3 tap peaking filter commonly used as an inverse Sinc compensator. Each are described in more detail below with links to other posts providing further details and example code.

My recommended approach in the case where optional sounding waveforms can be used would be a least squares approach using the "Wiener-Hopf" equations. I provide further details on how this works and have example MATLAB code that determines either the transfer function or the equalization for the transfer function (by swapping tx and rx in the function) at this post.

The use of this function is also demonstrated here showing how the delay for the channel can also be determined from the derived channel response.

If this approach is to be used, and assuming the stimulus could be modified, it is preferred to use a stimulus that is spectrally rich, as the frequency response can only be determined at frequencies where energy exists (and the error in the result is inversely proportional to the SNR received at any given frequency). For this reason, useful stimulus patterns are either frequency chirps or pseudo-random (PRN) sequences, which can be implemented with linear feedback shift registers. An example implementation of a PRN including MATLAB code is at this post. (That one is a GPS C/A Code generator as the sum of two PRN's but demonstrates how simple a single PRN can be constructed).

Alternatively the frequency response can be estimated from the FFT of this input and output of the OP's waveform, such that the input FFT is divided by the output FFT, and then the inverse FFT of that result can be the compensation filter. The result of this in the frequency domain should be reviewed first due to the likelihood of noise enhancement at out of band frequencies that should be reduced prior to the inverse FFT. This won't be as accurate as the recommended approach above, but may be sufficient and easy to generate.

Finally a third and very simple approach for high frequency enhancement is this 3-tap linear phase inverse Sinc filter which is general is parametrized for various values of high frequency peaking at the band edge of the waveform. This is used as pre-emphasis for the pass-band droop introduced by D/A converters and CIC filters, so may be sufficient for enhancing the bandwidth in the OP's case.

This may be possible, but you probably need a better way to measure the transfer function first.

The question didn't really contain all the relevant data, so I had to fudge it a little. It looks the the sample rate is 54 MHz and the excitation is a 2us long. With these assumptions I do get something that looks like your picture but this may be a little off in the details (which DO matter).

Now we can look at it in the frequency domain.

That's pretty ugly. The excitation itself is severely bandlimited and there are plenty of zeros in the magnitude spectrum. That's a bear to invert. The response shows two drop offs. One follows the main lobe of the excitation and there is another one at around 5.3 MHz. Let's zoom in on the main lobe region.

It's really hard to tell what's going on there. Technically the -3dB points are at 225 kHz for the excitation and maybe 180 kHz for the response but the frequencies are so low that the resolution (without interpolation) here is very poor . The response seems to follow (more or less) the excitation until the first zero but than it seems to hit a constant noise floor and doesn't show the comb filter pattern of the excitation.

Conclusion so far

While it's possible to work with your data, it will be very difficult. As the saying goes "garbage in, garbage out" and your measurement is problematic. I strongly recommend finding a better measurement method (sweeps, pseudo random noise, coherent averaging, etc) and carefully managing non-linearities and optimizing the signal to noise ratio specifically in the roll-off region.

The better the measurement, the easier it will be to invert it.

• That's a nice demonstration Hilmar! We can see from this that if the OP isn't concerned with phase distortion (which we can't see from this) that we can implement a peaking filter to have that first main lobe line up which would arguably extend the bandwidth 33% from 0.3 to 0.4. Agree that other stimulus is better suited for determining a frequency response in general. Commented Mar 25, 2023 at 15:19