# Decomposing a signal so that the magnitude spectrum of the decomposed signals lie in some specific amplitude range

Suppose I have the following signal:

I can compute its power magnitude spectrum:

PSD = np.abs(np.fft.rfft(signal))


Now I would like to pick a specific amplitude range, say between $$10^3$$ and $$10^0$$, and find a signal whose power magnitude spectrum matches PSD in that amplitude range and stays around the amplitude range in other areas. Something like this:

So in the amplitude range $$10^0-10^3$$, the new signal's power magnitude spectrum matches the PSD exactly, and outside of the amplitude range, the new signal's power magnitude spectrum is squished towards the amplitude range.

The end goal is to decompose the original signal into multiple signals whose power magnitude spectrums occupy smaller amplitude ranges, and then I would like to be able to recover the original signal exactly.

If there are any similar solutions, I would love to hear about them.

• Interesting -- usually one decomposes signals into frequency bands, not amplitude bands. If you don't mind, could you explain what's the use of such a decomposition?
– MBaz
Dec 12, 2023 at 17:20
• @MBaz I have found that neural networks focus around the largest amplitudes of the spectrum, meaning that higher amplitudes are predicted with greater accuracy while lower amplitudes are ignored. My intuition is then to decompose a signal and train a different network for each amplitude band. Dec 12, 2023 at 17:57

Maybe I'm not understanding you perfectly, but there's a couple things I'd like to clarify.

What you have denoted as PSD is not actually a PSD, it is a magnitude spectrum. The magnitude spectrum is defined as

$$$$\lvert X(\omega)\rvert^{2}$$$$

For a recent and pretty thorough discussion on the PSD and power spectrum, see a recent conversation I had here.

That being said, if you have a PSD, it is quite difficult to recover the original signal, especially if the signal is complex, as the PSD is related to the signal's autocorrelation. There are methods, but it's probably best to stick to the magnitude spectrum.

As to how to get a series of flatter spectrums, there are a couple methods that come to mind. One would be phase retrieval. You could hand craft a series of spectrums of interest, and then use a phase retrieval method like alternating projections to recover the signal that matches that spectrum. However, this would be quite difficult to recover the original signal from.

Another option could be whitening filters. Whitening filters flatten the spectrum. Once a whitening filter is applied, you can scale it to get it in the correct amplitude range. You can then add all these scaled, whitened versions together, and to recover the original signal, you would undo the scaling then the whitening. However, in this case, there is no guarantee that the spectrum in the amplitude region of interest of the whitened signal would match that of the original signal.

Overall, this seems a little ad hoc, and there probably isn't an exact science to a method like this. It's very reminiscent of bandpass filtering or channelizers, just done on the other axis. Anyways, I hope this helps at least give you some ideas on where to start, or some clarification on how to modify what you are aiming to achieve.

EDIT: I thought of an idea that could work. Let's say you have a spectrum $$X(\omega)$$. You can bandpass filter this so you get

$$$$\phi_{1-BP}(\omega) = H_{1-BP}(\omega)X(\omega)$$$$

Let's say you then also apply a whitening transform to get

$$$$\phi_{\mathcal{W}}(\omega) = \mathcal{W}\{X(\omega)\}$$$$

You can then form a new spectrum such that

$$$$\phi_{1-\mathcal{W}} = (1-H_{1-BP})\phi_{\mathcal{W}}(\omega) + \phi_{1-BP}(\omega)$$$$

This essentially replaces the frequency range of interest in the whitened spectrum with the original spectrum in that frequency range. You would just have to scale the whitened spectrum to fit in the amplitude range you are looking for, which may take some trial and error. To then reconstruct an estimate of the original signal, you can do something like

$$$$\hat{\phi}(\omega) = H_{1-BP}\phi_{1-\mathcal{W}}(\omega) + \ldots + H_{N-BP}\phi_{N-\mathcal{W}}(\omega)$$$$

I haven't worked an example out in code to verify whether or not this will actually work, but if I was trying to do what you are describing, this would probably be how I start approaching it.

• Thank you for your answer. Since I always have signals with decaying spectrums, do you think it would make sense to hard code intervals in the frequency axis to decompose the signal? I could just multiply the magnitude spectrum by different square functions—then it seems that I can recover the original signal. The comment on my question explains why I might want to do this. Dec 12, 2023 at 19:07
• You could, it just depends on the rate of decay of your spectrum. If you have too big of an amplitude range and too shallow of a slope, it might not work. I’m going to edit my answer with another idea, it’s probably too long to fit into a comment. Dec 12, 2023 at 20:59