Windowed Fourier Transform

Objectives: Windowed Fourier Transform (Short-Time Fourier Transform - STFT)

Windowed Fourier Transform (Short-Time Fourier Transform - STFT)

Time-Frequency Analysis

The classical Fourier Transform (FT) decomposes a signal into its frequency components, giving a clear picture of what frequencies exist in the signal. However, it does not provide any information about when these frequencies occur. This is because the FT assumes the signal is stationary over all time (it analyzes the whole signal as one piece).

Many real-world signals are non-stationary, meaning their frequency content changes over time (e.g., speech, music, heartbeats). To analyze such signals, we need a method that tells us how frequency content evolves over time. This is where the Windowed Fourier Transform, or Short-Time Fourier Transform (STFT), becomes useful.

What is the Short-Time Fourier Transform (STFT)?

STFT is a technique that breaks a signal into small overlapping time segments (windows) and performs the Fourier Transform on each segment. This way, we get a localized frequency analysis, showing the frequencies present at different times.

Mathematically, the STFT of a signal x(t) is defined as:

STFT(t, f) = ∫ x(τ) * w(τ - t) * e-j2πfτ

  • x(τ): The original signal as a function of time τ.
  • w(τ - t): A window function centered at time t that selects a portion of the signal around t.
  • e-j2πfτ: The complex exponential for frequency f.
  • STFT(t, f): The Fourier Transform result at time t and frequency f.

Explanation of Components:

  • The window function w(τ - t) isolates a small portion of the signal around time t. Common window shapes include rectangular, Hamming, Hann, and Gaussian.
  • By sliding this window along the signal (changing t), we analyze frequency content at different times.
  • The transform produces a two-dimensional function of time and frequency, showing how frequency components change over time.

Example Calculation

Suppose we have a signal x(t) composed of two sine waves that appear at different times:

  • From t = 0 to 1 second, frequency 5 Hz is present.
  • From t = 1 to 2 seconds, frequency 20 Hz is present.

If we apply a standard Fourier Transform on the entire 2-second signal, the result will show both 5 Hz and 20 Hz frequencies, but we won't know when each frequency occurs.

With STFT, we apply a window, say 0.5 seconds wide, and move it along the signal:

  • At t = 0.5 s window, the STFT will show a strong component at 5 Hz.
  • At t = 1.5 s window, the STFT will show a strong component at 20 Hz.

This way, the STFT provides a time-frequency representation that clearly shows when each frequency exists.

Window Function Choice and Its Impact

The choice of window w(t) affects the time and frequency resolution:

  • A narrow window (short duration) gives better time resolution (you can pinpoint frequency changes in time more precisely) but worse frequency resolution (frequency components are spread out).
  • A wide window gives better frequency resolution but worse time resolution.

This trade-off is a fundamental limitation and is related to the Heisenberg Uncertainty Principle in signal processing.

Limitations of Fourier Transform in Time Localization

The standard Fourier Transform analyzes the entire signal at once, losing all timing information. For signals whose frequency components change over time, the classical FT can only tell what frequencies are present but not when.

STFT solves this partially by windowing, but due to the fixed window size, it cannot provide very high time resolution and frequency resolution simultaneously. This trade-off means STFT is not perfect for all signals.

Summary

Concept Description
Classical Fourier Transform Transforms whole signal to frequency domain; no time info.
Short-Time Fourier Transform (STFT) Applies FT on windowed segments to get frequency info over time.
Window Function Weights the signal segment; choice affects resolution.
Time-Frequency Trade-Off Better time resolution means worse frequency resolution and vice versa.

Why Study STFT Deeply?

Understanding STFT helps in designing better signal processing techniques. It also opens the door to discovering or appreciating advanced methods such as Wavelet Transforms that can overcome some limitations of STFT by allowing variable window sizes. With deep insight, one might improve or invent transforms that better balance time and frequency resolutions.

20 Solved Examples on Windowed Fourier Transform (STFT) and Fourier Concepts

These examples cover practical use of STFT and related Fourier ideas, from simple to complex, to help you master the concepts. Each solution clearly explains formulas, symbols, and reasoning.


Example 1: Understanding the Window Function

Problem: Given a signal x(t), explain why we multiply it by a window function w(t) in STFT.

Solution:

In STFT, we analyze the signal in small time segments. The window function w(t) selects a segment around a time t0. Mathematically, we compute x(t) * w(t - t0), which means:

  • x(t): the original signal
  • w(t - t0): window centered at t0

This isolates the part of the signal near t0, so when we apply the Fourier Transform, we get frequency content localized at that time. Without the window, FT looks at the entire signal, losing time information.


Example 2: Calculate STFT of a Simple Signal

Problem: For signal x(t) = cos(2π10t), compute the STFT at time t=0 using a rectangular window w(t) = 1 for -0.5 ≤ t ≤ 0.5, else 0.

Solution:

STFT(t,f) = ∫ x(τ) * w(τ - t) * e-j2πfτ

At t=0:

STFT(0,f) = ∫ from -0.5 to 0.5 cos(2π10τ) * 1 * e-j2πfτ

Rewrite cosine using Euler's formula:

cos(2π10τ) = (ej2π10τ + e-j2π10τ)/2

So, STFT(0,f) = (1/2) ∫ from -0.5 to 0.5 [ej2π10τ + e-j2π10τ] * e-j2πfτ

= (1/2) ∫ from -0.5 to 0.5 [ej2π(10 - f)τ + e-j2π(10 + f)τ] dτ

Integrate each term:

∫ ej2πaτ dτ = (ej2πaτ) / (j2πa)

Calculate the definite integral:

(1/2) * [ (ej2π(10 - f)(0.5) - ej2π(10 - f)(-0.5)) / (j2π(10 - f)) + (e-j2π(10 + f)(0.5) - e-j2π(10 + f)(-0.5)) / (-j2π(10 + f)) ]

Using Euler formula for sine:

This expression simplifies to:

STFT(0,f) = (1/2) * [ sin(π(10 - f)) / (π(10 - f)) + sin(π(10 + f)) / (π(10 + f)) ]

Interpretation: This shows peaks near frequencies f=10 Hz and f=-10 Hz (due to cosine symmetry). The sinc-like terms are due to the rectangular window's effect.


Example 3: Effect of Window Width on Frequency Resolution

Problem: Why does increasing the window length improve frequency resolution in STFT?

Solution:

The frequency resolution ∆f is roughly the inverse of the window length T: ∆f ≈ 1 / T.

  • A longer window (larger T) means the Fourier Transform analyzes a longer signal segment, which allows it to distinguish closer frequencies (better frequency resolution).
  • But a longer window reduces time resolution because the analysis window averages over a longer time.

Formula symbol meanings:

  • ∆f: smallest frequency difference that can be resolved
  • T: window length in seconds

Example 4: Calculate STFT for a Signal with Two Frequencies Appearing at Different Times

Problem: Signal x(t) is 5 Hz sine from 0 to 1 second and 15 Hz sine from 1 to 2 seconds. Using a 0.5 s Hamming window, sketch the expected STFT time-frequency plot.

Solution:

The STFT will slide the 0.5 s window from 0 to 2 seconds:

  • From 0 to about 1 second, the STFT magnitude will peak at 5 Hz.
  • From 1 to 2 seconds, the peak moves to 15 Hz.

The Hamming window smooths edges, so the transitions between frequencies will appear gradual.


Example 5: Time-Frequency Trade-Off Calculation

Problem: If you want to detect frequency changes occurring within 0.1 seconds, what window length should you choose? What is the frequency resolution?

Solution:

  • To detect changes within 0.1 seconds, window length T should be ≈ 0.1 s (to have good time localization).
  • Frequency resolution ∆f ≈ 1 / T = 1 / 0.1 = 10 Hz.
  • This means frequencies closer than 10 Hz will not be well separated.

Example 6: Compare Rectangular and Gaussian Window Effects on STFT

Problem: Explain the advantage of Gaussian window over rectangular window in STFT.

Solution:

Rectangular window causes sharp edges, leading to spectral leakage and ringing in frequency domain. Gaussian windows are smooth, reducing leakage and providing better balance of time-frequency localization.


Example 7: STFT of a Signal with a Frequency Sweep

Problem: A chirp signal whose frequency increases linearly from 5 Hz to 25 Hz over 2 seconds is analyzed with STFT. Describe what the time-frequency plot shows.

Solution:

The STFT plot will show a ridge starting near 5 Hz at time 0 and rising to 25 Hz at 2 seconds, reflecting the frequency increase over time.


Example 8: Fourier Transform of a Rectangular Pulse

Problem: Compute the Fourier Transform of a rectangular pulse of width T centered at zero.

Solution:

Rectangular pulse: rect(t/T) = 1 for |t| ≤ T/2, else 0.

Fourier Transform:

F(ω) = ∫ from -T/2 to T/2 1 * e-jωt dt = [e-jωt/(-jω)] from -T/2 to T/2

Calculates to:

F(ω) = (2/jω) * sin(ωT/2)

Or rewritten as:

F(ω) = T * sinc(ωT/2π), where sinc(x) = sin(πx)/(πx)

Interpretation: The rectangular pulse transforms to a sinc function in frequency, showing frequency content spread around zero.


Example 9: Using Parseval's Theorem

Problem: Verify the energy of signal x(t) = cos(2π10t) over 1 second using Parseval’s theorem.

Solution:

Energy in time domain: E = ∫ |x(t)|² dt from 0 to 1.

Since cos²(θ) = (1 + cos(2θ))/2,

E = ∫ from 0 to 1 (1 + cos(40πt))/2 dt = (1/2) * ∫0¹ 1 dt + (1/2) * ∫0¹ cos(40πt) dt

Calculate:

(1/2)*1 + (1/2)*(sin(40π*1) - sin(0))/40π = 0.5 + 0 = 0.5

Parseval’s theorem states total energy in time = total energy in frequency domain. This confirms signal energy = 0.5 over 1 sec.


Example 10: Effect of Time Shift on Fourier Transform

Problem: Find the Fourier Transform of x(t - t0) if FT of x(t) is X(f).

Solution:

Using the time-shift property:

FT[x(t - t0)] = e-j2πf t0 X(f)

This means a time shift causes a phase shift in the frequency domain, without changing magnitude.


Example 11: Frequency Shifting in Fourier Transform

Problem: If FT of x(t) is X(f), find FT of x(t) * ej2πf0 t.

Solution:

Frequency shift property:

FT[x(t) * ej2πf0 t] = X(f - f0)

This shifts the spectrum by f0 Hz.


Example 12: STFT Calculation for Discrete Signal

Problem: Given discrete signal x[n] = sin(2π*0.1*n) for n=0 to 49, compute STFT with window length 10 samples at position n=20.

Solution:

Extract windowed signal: x_win[k] = x[20 - 5 + k], k=0 to 9

Compute DFT of x_win to get STFT at n=20.

Because window is short, expect peak near normalized frequency 0.1.


Example 13: Convolution Theorem Application

Problem: Explain why convolution in time domain corresponds to multiplication in frequency domain.

Solution:

If y(t) = x(t) * h(t) (convolution), then FT[y(t)] = X(f) × H(f).

This is useful because convolution (which is an integral) becomes a simple product in frequency domain, simplifying many signal processing tasks.


Example 14: Effect of Window Type on STFT Magnitude

Problem: Compare the STFT magnitude spectrum of a sine wave windowed by rectangular and Hamming windows.

Solution:

Rectangular window produces sinc-shaped main lobe with high side lobes (spectral leakage).

Hamming window reduces side lobes (less leakage) but broadens main lobe (less frequency resolution).


Example 15: Using STFT to Detect Speech Phonemes

Problem: Explain how STFT helps in identifying phonemes in speech signals.

Solution:

Phonemes have characteristic frequency patterns that change rapidly over time.

STFT allows us to visualize how frequencies change over short time windows, making it possible to segment and classify different phonemes based on their time-frequency signatures.


Example 16: Relation Between STFT and Spectrogram

Problem: Define a spectrogram and its relation to STFT.

Solution:

Spectrogram is the squared magnitude of the STFT:

Spectrogram(t, f) = |STFT(t, f)|²

It represents signal power over time and frequency, often visualized as a heat map.


Example 17: STFT Window Overlap Effect

Problem: Why do we use overlapping windows in STFT?

Solution:

Overlapping windows reduce artifacts from window edges, provide smoother time-frequency representation, and improve time resolution without sacrificing frequency resolution too much.


Example 18: Fourier Transform of a Gaussian Function

Problem: Show that FT of Gaussian f(t) = e-a t² is also a Gaussian.

Solution:

FT[f(t)] = ∫ e-a t² e-j2π f t dt = √(π/a) e-(π² f²)/a

This dual Gaussian nature makes Gaussian windows optimal for joint time-frequency localization.


Example 19: Discrete Fourier Transform (DFT) Computation

Problem: Compute the DFT of x = [1, 0, -1, 0].

Solution:

DFT formula: X[k] = ∑ x[n] e-j2πkn/N, n=0 to N-1

N=4.

  • X[0] = 1 + 0 + (-1) + 0 = 0
  • X[1] = 1*1 + 0*(-j) + (-1)*(-1) + 0*j = 1 + 0 + 1 + 0 = 2
  • X[2] = 1*1 + 0*1 + (-1)*1 + 0*1 = 1 + 0 -1 + 0 = 0
  • X[3] = 1*1 + 0*j + (-1)*(-1) + 0*(-j) = 1 + 0 + 1 + 0 = 2

Example 20: Designing a Bandpass Filter Using FT

Problem: How to design a filter that passes frequencies between 5 and 15 Hz using frequency domain multiplication?

Solution:

Define filter transfer function H(f): H(f) = 1 for 5 ≤ |f| ≤ 15, else 0.

Filter output Y(f) = X(f) × H(f)

Inverse FT of Y(f) gives filtered signal.

This works because multiplication in frequency domain corresponds to filtering in time domain.


These 20 examples illustrate foundational and applied knowledge for mastering Fourier and STFT concepts. They explain formulas, symbols, and reasoning to build deep understanding.

Reference Book: N/A

Author name: SIR H.A.Mwala Work email: biasharaboraofficials@gmail.com
#MWALA_LEARN Powered by MwalaJS #https://mwalajs.biasharabora.com
#https://educenter.biasharabora.com

:: 2.2::