**Update January 31, 2023**: I’ve added numbers in square brackets next to the worst of the wrong things. I’ll document the errors at the bottom of the post.

Of course I have to see what ChatGPT has to say about CSP. Including definitions, which I don’t expect it to get too wrong, and code for estimators, which I expect it to get very wrong.

Let’s take a look.

A vexing problem I’m having is that every single time I login to OpenAI on a computer, “ChatGPT is a capacity right now.” And every single time I login on my phone, I can interact with it no problem. But capturing the output from the phone and bringing it to the CSP Blog is not as convenient as using Chrome for both.

Anyway, here is a transcribed interaction:

**CSP Blog**: What is the spectral correlation function?

**ChatGPT**: The spectral correlation function (SCF) is a mathematical function that describes the correlation between two signals or signal components in the frequency domain. It is often used in signal processing and communication systems to analyze the frequency-dependent characteristics of a signal, such as its bandwidth and power spectral density [1]. The SCF is typically computed by taking the Fourier transform of the cross-correlation function of the two signals, and can be used to identify the presence of certain frequency components in a signal, and their relative strengths [2].

**CSP Blog**: Define the cyclic temporal cumulant function

**ChatGPT**: The cyclic temporal cumulant function is a mathematical function that describes the cyclic temporal structure of a signal [3]. It is related to the cyclic autocorrelation function, which describes the cyclic correlation between different points in a signal, but instead of measuring correlation, it measures cumulants. Cumulants are a measure of the deviation of a signal from a normal distribution and are used to describe the signal’s statistical properties.

The cyclic temporal cumulant function is typically calculated by taking the Fourier transform of the cyclic autocorrelation function of the signal [4], and it can be used to identify the presence of certain cyclic patterns in a signal [5], and their relative strengths. It is often used in signal processing and communication systems to analyze the time-dependent characteristics of a signal, such as its periodicity [6] and frequency content [7].

**CSP Blog**: Define the cyclic autocorrelation function

**ChatGPT**: The cyclic autocorrelation function is a mathematical function that describes the cyclic correlation between different points in a signal. It is used to measure the similarity between a signal and a version of itself that has been shifted in time [8].

The cyclic autocorrelation function is calculated by taking the inner product of a signal with itself at different time lags [9], and it is often represented as a function of the time lag. It can be used to identify the presence of certain cyclic patterns in a signal, and their relative strengths. For example, a signal with a strong cyclic pattern will have a high cyclic autocorrelation at the time lag corresponding to the period of the pattern [10].

It is often used in signal processing and communication systems to analyze the time-dependent characteristics of a signal, such as its periodicity [11] and frequency content [12]. It is also used in cyclostationary signal processing for detecting the presence of cyclostationary signals and for estimating the parameters of the cyclostationary signals.

**CSP Blog**: Write code to estimate the spectral correlation function

**ChatGPT**: Here is some sample Python code to estimate the spectral correlation function of a signal using the Welch method [13]:

```
import numpy as np
from scipy.signal import welch
# Input signal
x = ...
# Window function
window = ...
# Number of samples in each segment
nperseg = ...
# Number of points to use in the FFT
nfft = ...
# Overlap between segments
noverlap = ...
# Estimate the power spectral density
f, Pxx = welch(x, window=window, nperseg=nperseg, nfft=nfft, noverlap=noverlap)
# Estimate the spectral correlation function
Rxx = np.real(np.fft.ifft(Pxx))
In this example, 'x' is the input signal, 'window' is the window function to use (e.g. 'hanning', 'hamming', etc.), 'nperseg' is the number of samples in each segment, 'nfft' is the number of points to use in the FFT, and 'noverlap' is the number of samples that the segments should overlap. The function 'welch' is used to estimate the power spectral density of the signal. The power spectral density estimate is then converted to the spectral correlation function using the inverse Fourier transform.
```

**CSP Blog**: Write code to estimate the cyclic temporal cumulant function

**ChatGPT**: I’m sorry, I am a text-based AI and I cannot execute code. However, I can explain how the code for estimating the cyclic temporal cumulant function might look like in a language like python. Here’s an example of how the code might look like [14]:

```
import numpy as np
def
cyclic_temporal_cumulant(x, k):
"""
Estimate the kth order cyclic temporal cumulant of a signal x.
"""
N = len(x)
X = np.fft.fft(x)
R = np.real(X * np.conj(X)) / N
c = np.fft.ifft(R)
return c[k]
x = ... # input signal
k = ... # order of cumulant
c = cyclic_temporal_cumulant(x, k)
```

This code defines a function ‘cyclic_temporal_cumulant’ that takes two inputs: the signal ‘x’ and the order of cumulant ‘k’. The function first calculates the Fourier transform of the signal using the ‘fft’ function from the NumPy library, and then calculates the magnitude-squared of the Fourier transform, which is the cyclic autocorrelation function of the signal [15]. Finally, it takes the inverse Fourier transform of the cyclic autocorrelation function to get the kth order cyclic temporal cumulant [16].

It’s important to note that this is just a simple example and it might not work well for some signals, you should use appropriate windowing, check the signal’s length, and decide on the order of cumulant based on the signal’s properties.

**CSP Blog**: Write code for estimating the cyclic polyspectrum

**ChatGPT**: I’m sorry … [Same caveat as above]

```
import numpy as np
def cyclic_polyspectrum (x, k):
"""
Estimate the kth order cyclic polyspectrum of a signal x.
"""
N = len(x)
X = np.fft.fft(x)
R = np.real(X * np.conj(X)) / N
c = np.fft.ifft(R)
c_cumulant = np.zeros(n, dtype=complex)
c_cumulant[k] = c[k]
for i in range(i, k):
c_cumulant[i] = c_cumulant[i-1] - c[i]
return np.fft.fft(c_cumulant)
x = ... # input signal
k = ... # order of cumulant
P = cyclic_polyspectrum(x, k)
```

This code defines a function ‘cyclic_polyspectrum’ that takes two inputs: the signal ‘x’ and the order of cumulant ‘k’. The function first calculates the Fourier transform of the signal using the ‘fft’ function from the NumPy library, and then calculates the magnitude-squared of the Fourier transform, which is the cyclic autocorrelation function of the signal. Then it takes the inverse Fourier transform of the cyclic autocorrelation function to get the kth order cyclic cumulant of the signal. Then it calculates the kth order cyclic cumulant by subtracting the cumulant of lower order, and finally, it takes the Fourier transform of the cumulant to get the kth order cyclic polyspectrum of the signal [17].

Some thoughts.

First, I’m in zero danger of being out of a job due to large language models (LLMs) like ChatGPT. Yay!

Second, almost everything in ChatGPT’s responses above is wrong, misleading, or so confused and jumbled up that it is *not even wrong*. But–silver-lining alert–you can use the posts on this website, the CSP Blog, to find all the errors. Just please don’t use code generated by ChatGPT and then ask me to help you debug it. Better to start from scratch on your own. And looking at ChatGPT’s code makes me dizzy.

Third, the responses sound eerily familiar. These kinds of mixed-up not-even-wrong mathematical incoherencies are cropping up more and more often in the papers I review for journals, review for the CSP blog, and read in publications. And that’s where ChatGPT gets its training data: the world of human-generated stuff. So maybe there is a circling-the-drain vicious circle here: Bad papers get published, LLMs trawl the internet and find them, bad researchers use ChatGPT and publish, and the cycle continues.

Finally, why do we want this stuff? Suppose ChatGPT gave flawless answers and code. Why do we want to offload our intellectual efforts, pursuits, failures, and successes to a machine? I can understand a *better* tool: A more efficient mousetrap, fishing net, radio antenna. I can understand a different *kind* of tool: smoke signals, then pony express, then telegraph, then telephone, then WiFi. But those things enable us to work better, live better, be healthier, communicate better, etc. How will a *complete* offloading of our efforts, our struggles to create and understand, to a machine help us? Probably a better question is: Why do the engineers creating ChatGPT and Dall-E want this stuff?

After the post is up for a while, I’ll go back and highlight the howlers.

[1] The spectral correlation function is not used to measure the bandwidth of a signal; in fact you’d go quite wrong if you tried. The width of the symbol-rate spectral correlation function for a low-excess-bandwidth QAM/PSK signal is a small fraction of the actual occupied bandwidth. And saying that the spectral correlation function is used to ‘analyze the power spectral density’ is not actually, technically, wrong, since the power spectrum is a slice of the non-conjugate spectral correlation function, it is just misleading.

[2] Suppose I gave you the correlation between two random variables and . Could you then tell me the relative strengths (say, the individual standard deviations, or just their individual sample values) from that number? Again, this is power-spectrum-y talk mixed with spectral-correlation-y terms. We’ll see that this is a common theme in Chat-GTP’s responses.

[3] A near tautology, except for the fuzziness of the phrase “*cyclic temporal structure*.” Obvious bot is obvious.

[4] “*The cyclic temporal cumulant function is typically calculated by taking the Fourier transform of the cyclic autocorrelation function of the signal*” And here is where we get into the harm of Chat-GPT and its ilk. Stated confidently and oh-so-knowingly. You know, it is *typically* calculated like that, but I’m not going to bore you with all the other ways … And of course it is wrong in the extreme. Not only is it not typically calculated by Fourier transforming the cyclic autocorrelation, it is never calculated by doing that. See the cyclic cumulant and cyclic-cumulant estimation posts for the real story.

[5] What are “*cyclic patterns in the signal*“?

[6] “*It *[cyclic cumulant]* is often used in signal processing and communication systems to analyze the time-dependent characteristics of a signal, such as its periodicity*” Well, no, it is not. At all. In fact, a properly calculated cyclic temporal cumulant of order two or greater reflects those statistical characteristics of the signal that do not depend on any periodic component!

[7] “*It *[cyclic cumulant]* is often used in signal processing and communication systems to analyze the time-dependent characteristics of a signal, such as its periodicity and frequency content*” Frequency content? In a temporal parameter?

[8] “*The cyclic autocorrelation function is a mathematical function that describes the cyclic correlation between different points in a signal. It is used to measure the similarity between a signal and a version of itself that has been shifted in time*.” That’s the normal autocorrelation function. The cyclic autocorrelation can be interpreted as measuring the similarity between a signal and a version of the signal that has been shifted in time and subjected to a frequency shift. Or the similarity between two time- and frequency-shifted versions of a signal.

[9] “*The cyclic autocorrelation function is calculated by taking the inner product of a signal with itself at different time lags*” See [8].

[10] “*a signal with a strong cyclic pattern will have a high cyclic autocorrelation at the time lag corresponding to the period of the pattern*” Well, no, not necessarily. In fact, for the CSP-Blog mascot signal, the rectangular-pulse BPSK signal, the cyclic autocorrelation function is associated with the period equal to the bit duration (reciprocal of the bit rate), and the cyclic autocorrelation slices for all cycle frequencies (including zero!) is equal to zero for a lag equal to the bit duration! Same is true for any rectangular-pulse PSK or QAM signal. See the cyclic autocorrelation gallery post for lots of examples. Plenty of real-world signals also disobey this Chat-GPT hallucination:

Here the fundamental period of the time-varying autocorrelation is 1/[1.23 MHz] = 0.81 s.

[11] “*It *[cyclic autocorrelation]* is often used in signal processing and communication systems to analyze the time-dependent characteristics of a signal, such as its periodicity*” See [6].

[12] “*It *[cyclic autocorrelation]* is often used in signal processing and communication systems to analyze the time-dependent characteristics of a signal, such as its periodicity [11] and frequency content*” See [7].

[13] The Welch method refers to a spectrum estimator–an estimator of the PSD. The generalization of the Welch method to the spectral correlation function is what I call the time-smoothing method. The provided code does this: Estimate the PSD using the Welch method, inverse transform the PSD estimate to yield the autocorrelation, then declare that the autocorrelation is the spectral correlation function estimate. Simple! Won’t somebody please–please!–think of the children?? They will learn the wrong things. So wrong. And then us AI skeptics and holdouts will have to help them unlearn. Thanks OpenAI!

[14] The proffered code does this: compute the Fourier transform of the input, form the periodogram, inverse Fourier transform the periodogram to form an estimate of the autocorrelation, then declare that the element of the autocorrelation function estimate is actually the th-order cyclic cumulant estimate! Oh the humanity! Or utter lack thereof.

[15] “*and then calculates the magnitude-squared of the Fourier transform, which is the cyclic autocorrelation function of the signal*” Well, no, not at all. The (scaled) magnitude-squared of the Fourier transform is the periodogram.

[16] “*Finally, it takes the inverse Fourier transform of the cyclic autocorrelation function to get the kth order cyclic temporal cumulant*” See [14].

[17] Too bizarre to untangle. This is not even in the same universe as the actual cyclic polyspectrum.

What kills me is the way they’ve set up Chat-GPT to always sound so utterly confident and sure. Why can’t it just say “I don’t know” instead of vomiting up a bunch of crap and then acting like it is bored even having to tell you these obvious things?

This AI tool will harm the education of young people.

Such a relief to read this blog !

The hype around chatGPT is scary, because as you said at end, this kind of tools can harm the education of the younger generations… if used inappropriately. I think it might be useful for certain applications, much like the calculator, but presenting it as a real break through in AI is what makes it quite contrevarsial.

Great post!

You should retry this with GPT-4 (just released this week). Seems to improved somewhat. As an example, here is the output to one your previous queries “Define the cyclic autocorrelation function”.

The cyclic autocorrelation function (CAF) is a powerful tool in signal processing for analyzing cyclostationary signals, which are signals whose statistical properties vary periodically with time. The CAF is a two-dimensional function that measures the correlation between a signal and its time-shifted and frequency-shifted versions. In essence, the CAF extends the concept of the conventional autocorrelation function by introducing an additional frequency parameter, called the cycle frequency.

Mathematically, the cyclic autocorrelation function R_x(τ, α) of a discrete-time signal x[n] is defined as:

R_x(τ, α) = lim (N -> ∞) (1/N) Σ x[n] * conj(x[n+τ]) * exp(-j2παn/N)

where:

τ is the time lag

α is the cycle frequency

conj() denotes the complex conjugate

j is the imaginary unit (i.e., √(-1))

N is the number of samples in the signal

The summation runs over n from 0 to N-1

In practice, when dealing with finite-length signals, the limit is replaced with a finite summation over the available samples.

The cyclic autocorrelation function is particularly useful for detecting and characterizing the cyclostationary features in signals, which may include communication signals, radar signals, and many other types of time-varying signals.

Hello Eric and welcome to the CSP Blog! I appreciate the comment.

I agree the text is better. Maybe Chat GPT 4 has read the CSP Blog whereas Chat GPT 3 did

not? 🙂

But the inclusion of the factor of in the argument of the exponential is disastrous.

If you associate the with , you’re correlating the delay product with a sine wave

corresponding to expanded time relative to the time steps of the delay product.

If you associate the with then the limit is just the autocorrelation

because as .