# Create filter without regard to phase response (amplitude only)

## Why I only care about amplitude response

I'm working on equalizing a DAC where I only care about the flatness of an AWGN spectrum. Since AWGN has random phase for any frequency bin, I do not care about correcting phase response at all; only "flatness".

## Calibration Setup

I'll be playing a CAZAC training sequence out of the DAC and noting the magnitudes on a spectrum analyzer. It will be fairly easy to determine what the desired gain for some frequency $$D(f_\xi)$$ should be.

## Problem formulation

I am trying to find time domain taps $$h$$ such that the error between the desired frequency response gain ($$D$$) and the tap frequency response ($$H$$) is minimized after neglecting any error due to phase ($$e^{j \phi(\xi)}$$) since I only care about $$\left| H(f_\xi) \right|$$ vs. $$\left| D(f_\xi) \right|$$.

$$\left[ \begin{array}{c} H(f_0) \\ H(f_1) \\ \vdots \end{array} \right] \overset{\textrm{LS}}{\textrm{=}} \left[\begin{array}{c} D(f_0) \\ D(f_1) \\ \vdots \end{array} \right] \cdot \left[ \begin{array}{c} e^{j \phi(f_0)} \\ e^{j \phi(f_1)} \\ \vdots \end{array} \right]$$

The final thing I want to solve for is the time domain tap values:

$$\left[ \begin{array}{c c} W_{0,0} & W_{0,1} \\ W_{1,0} & W_{1,1} \\ W_{2,0} & W_{2,1} \end{array} \right] \cdot \left[ \begin{array}{c} h_0 \\ h_1 \end{array} \right] \overset{\textrm{LS}}{\textrm{=}} \left[\begin{array}{c} D(f_0) \\ D(f_1) \\ D(f_2) \end{array} \right] \cdot \left[ \begin{array}{c} e^{j \phi(f_0)} \\ e^{j \phi(f_1)} \\ e^{j \phi(f_2)} \end{array} \right]$$

where $$W_{\xi,m} = \exp\left(- j 2 \pi f_\xi m \right)$$ with $$N=2$$ in this example.

Note the definition of the DFT in the $$W$$ matrix:

$$H(f_\xi) = \sum_{m=0}^{N-1} \exp\left(- j 2 \pi f_\xi m \right)$$

The difficulty in solving this problem is in determining what $$\phi(f_\xi)$$ should be in order to make the Least Squares (LS) algorithm work best. I am already useing LS equalization (to great effect) elsewhere in this design to correct for phase and amplitude error.

• a CAZAC sequence is fundamentally different than WGN!, You'd care about the phase response, as that defines the group delay, an suddenly you have dispersion on your formerly nice CAZAC sequence; I'm assuming you were planning to sweep the spectrum analyzer together with the CAZAC's instantaneous frequency. Are you sure you only care about amplitude response here? Dec 20, 2021 at 23:53
• Yes, I'm sure I only care about amplitude response. The CAZAC sequence removes the need to do a long averaging capture on the spectrum analyzer; the power spectrum of a CAZAC is a comb. The actual signal I care about will be AWGN. Dec 21, 2021 at 0:23
• Why don't you just design a linear phase filter with its magnitude approximating the desired magnitude response? Dec 21, 2021 at 10:55
• @philn: You can, but I'm pretty sure that that's not what you want, because if the magnitude is not an even function of $\omega$, then the filter is complex-valued, i.e., you get complex-valued coefficients. Any real-valued filter has an even magnitude response, regardless of its phase. Dec 21, 2021 at 18:24
• @MattL. This isn't for audio. It's a complex signal with complex taps at > 1 GHz IF. Doing a reverse hilbert transform isn't out of of the question if there's some way to equalize it though. Dec 21, 2021 at 18:30

A minimum phase filter might produce a better least squares fit than a linear phase filter of the same number of taps.

So I would estimate the pole zero locations for a minimum phase IIR filter. Then use the phase results sampled from the frequency response of that that IIR filter to calculate a least square fit for a FIR filter.

For estimating pole zero locations, there's a chapter in Lyon's Streamlining DSP book on "Designing Nonstandard Filters with Differential Evolution" which combines stochastic descent with a genetic algorithm. (or use other root finding methods). Then flip all the zeros inside (or leftward) for min phase.

The phase is given by the delay and should be such that would match the desired delay of the filter. Given the filter must be causal, this would optimally be in the middle of the filter (as a linear phase filter) as long as there isn't any constraint on delay. Centering the delay using least squares equalization is further detailed in this link:

Compensating Loudspeaker frequency response in an audio signal

• I'm starting to do experimental code and while having the group delay of $\phi(f)$ be centered ($\phi(f) = \exp( -j 2 \pi f N/2)$ gives good results it is quite far from the best result. This makes me think the actual optimal solution is more difficult to get. Dec 22, 2021 at 17:42
• @philn you want the span of the equalizer to match the delay spread of the channel--too short and you are not capturing all of the multipath and too long and you will add noise enhancement with no other gain. I review the resulting coefficients and adjust accordingly such that the impulse response is centered properly and decays to the "noise floor" without extending much further. Dec 22, 2021 at 20:43
• @philn since you mentioned that you are equalizing a DAC, is it simply and inverse Sinc filter that you need? Dec 23, 2021 at 18:57

If the phase is irrelevant, you might as well design a linear phase filter. The reason for choosing a linear phase is that the design problem can be formulated as a linear problem, which makes it easy to solve, and which guarantees that there is only one globally best solution. The fact that the filter coefficients are complex-valued (which I understood from your comment) doesn't make the problem any harder.

You can formulate a linear least-squares problem, which can be solved by solving a set of linear equations. You can use the Matlab/Octave function cfirls to design the filter. That function can design complex-valued FIR filters with prescribed magnitude and phase responses. In your case you should define a linear phase as the desired phase:

$$\phi(\omega)=-\frac{N-1}{2}\omega\tag{1}$$

where $$N$$ is the filter length (number of taps).