File:Comparison of symmetric and periodic Gaussian windows.svg

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Original file(SVG file, nominally 652 × 743 pixels, file size: 108 KB)

Captions

Captions

Add a one-line explanation of what this file represents

Summary[edit]

Description
English: These figures compare two 8-length Gauss window functions and their spectral leakage (discrete-time Fourier transform) characteristics. The function labeled DFT-even is a truncated version of a 9-length symmetric window, whose DTFT is also shown (in green). All three DTFTs have been sampled at the same frequency interval (by an 8-length DFT). In the case of the 9-length window, that is done by combining its first and last coefficients by addition (called periodic summation, with period 8). Because of symmetry, those coefficients are equal. So in a spectral analysis (of data) application, an equivalent operation is to add the 9th data sample to the 1st one, and apply the same 8-length DFT-even window function seen in the top figure.
Date
Source Own work
Author Bob K
Permission
(Reusing this file)
I, the copyright holder of this work, hereby publish it under the following license:
Creative Commons CC-Zero This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication.
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.

Other versions

Also see File:Sampling_the_Discrete-time_Fourier_transform.svg.
This file was derived from: Two 8-point Gaussian window functions.svg
This file was derived from: Spectral leakage from two 8-point Gaussian windows.png

This file was derived from: Comparison of symmetric and periodic triangular window functions.svg
SVG development
InfoField
 
The source code of this SVG is invalid due to 3 errors.
 
This W3C-invalid vector image was created with LibreOffice.
Usage
InfoField
Additional information and an external link to this image can be found at Window_function#DFT-even.
Octave/gnuplot source
InfoField
click to expand

This graphic was created with the help of the following Octave script:

function out=gauss(M,sigma)
out = exp(-.5*(((0:M)-M/2)/(sigma*M/2)).^2);
endfunction

% Options
  frame_background_gray = true;

  if frame_background_gray
   graphics_toolkit("qt")         % has "insert text" option
%  graphics_toolkit("fltk")       % has cursor coordinate readout
   frame_background = .94*[1 1 1];
   d  = 4;                        % amount to add to text sizes
   dl = 16;                       % amount to large marker size
  else
   graphics_toolkit("gnuplot")    % background will be white regardless of value below
   frame_background = .94*[1 1 1];
   d=0; ds = 0; dl = 0;
  endif

% (https://octave.org/doc/v4.2.1/Graphics-Object-Properties.html#Graphics-Object-Properties)
% Speed things up when using Gnuplot
  set(0, "DefaultAxesFontsize",10+d)   % size of numeric tick labels
  set(0, "DefaultLineLinewidth",1)
  set(0, "DefaultLineMarkersize",14+dl)
  set(0, "DefaultTextFontsize",12+d)
  set(0, "DefaultFigureColor",frame_background)
  
  darkgreen = [33 150 33]/256;

  M=7*8*100;        	% big number, divisible by 7 and 8
% Generate M+1 samples of a Gaussian window
  window = gauss(M, 0.4);
  N=8;                  % actual window size, in "hops"

% Sample the window.
% Scale the abscissa. 0:M samples --> 0:7 "hops", and take 8 symmetrical hops, from 0 to 7
  sam_per_hop_7 = M/7;
% symmetric8 = window(1+(0:7)*sam_per_hop_7);
  symmetric8 = gauss(7,0.4);

% Scale the abscissa. 0:M samples --> 0:8 "hops", and take 9 symmetrical hops, from 0 to 8
  sam_per_hop_8 = M/8;
% symmetric9 = window(1+(0:8)*sam_per_hop_8);
  symmetric9 = gauss(8,0.4);
  periodic8  = symmetric9(1:8);
  periodic_summation = [symmetric9(1)+symmetric9(N+1) symmetric9(2:N)];

% Compare windows based on their processing gain (PG) (Harris,1978,p 56,eq 15), because the ENBW
% formula allows values less than one "bin" (for some windows) when used with a 9-point periodic 
% summation and an 8-point DFT.  That actually makes sense, because a bandwidth of 1.1 (for instance)
% measured in 1/9-width bins is only 0.98 measured in 1/8-width bins. But values less than one
% are not customary, which could cause distrust.
  PG_symmetric8 = sum(symmetric8)^2/sum(symmetric8.^2)	% 4.9281
  PG_periodic8  = sum(periodic8)^2 /sum(periodic8.^2)	% 5.5046
  PG_symmetric9 = sum(symmetric9)^2/sum(symmetric9.^2)	% 5.6239

% Also note that the correct incoherent "power" measurement for the
% periodic_summation window is sum(symmetric9.^2),
% not sum(periodic_summation.^2), because
% E{(h(1)·X(1) + h(9)·X(9))^2} = (h(1)^2 + h(9)^2)·E{X^2},
% not (h(1)^2 + 2·h(1)·h(9) + h(9)^2)·E{X^2}.
%------------------------------------------------------------------
% Plot the points
  figure("position", [100 100 700 400], "color",frame_background)
#{
  x1 = .06;               % left margin
  x2 = .02;               % right margin
  y1 = .10;               % bottom margin for annotation
  y2 = .08;               % top margin for title

  width = 1-x1-x2;
  height= 1-y1-y2;

  x_origin = x1;
  y_origin = 1;           % start at top of graph area
%=======================================================
  y_origin = y_origin -y2 -height;        % position of top row
  subplot("position",[x_origin y_origin width height])
#}

% These unusual looking coordinates are default values assigned by gnuplot.
% In order to force qt to do the same, I measured them and put them here.
  original = [.077 .1275 .970-.077 .865-.1275];
  subplot("position", original)

  plot(0:7, symmetric8,  "color","red",   ".")
  hold on
  plot(8, symmetric9(9), "color","green", ".")
  plot(0:7, periodic8,   "color","blue",  ".")

% Connect the dots
  hops = (0:M)/sam_per_hop_8;
  plot(hops , window, "color","blue")         % periodic

 hops = (0:M)/sam_per_hop_7;
 plot(hops, window, "color","red")           % symmetric

 xlim([0 8])
 grid on
 set(gca, "xgrid","on")
 set(gca, "ygrid","on")
 set(gca, "ytick",[0:.25:1])
 set(gca, "xtick",[0:8])

 title("8-point Gaussian window functions", "fontsize",14+d, "fontweight","normal");
 xlabel('\leftarrow  n  \rightarrow', "fontsize",14+d, "fontweight","bold")

 text(3.74, .56, 'symmetric \rightarrow', 'color', 'red')
 str = {'\leftarrow periodic','     ("DFT-even")'};
 text(5.1, .813, str, 'color', 'blue')

if frame_background_gray
  annotation("textarrow", [.737 .954], [.233 .158], "color",darkgreen,...
        "string",{"discarded OR added to value at n=0";...
        "             (periodic summation)"}, "fontsize",10+d,...
        "linewidth",1.5, "headstyle","vback1", "headlength",5, "headwidth",5)
else
% After this call, the gnuplot cursor units change to a normalized ([0,1]) coordinate system
  annotation("textarrow", [.737 .954], [.233 .158], "color",darkgreen,...
        "string",{"discarded OR added to value at n=0                     ";...
        "             (periodic summation)"}, "fontsize",10+d,...
        "linewidth",1.5, "headstyle","vback1", "headlength",5, "headwidth",5)
endif

%==================================================================
% Now compute and plot the DTFTs and DFTs
  M = 64*N;      % DTFT size
  dr = 80;       % dynamic range (decibels)
%------------------------------------------------------------------
  figure("position", [100 200 700 400], "color",frame_background)
  subplot("position", original)

% Do the DFT plots first, followed by legend(), because we want legend() to display only 3 dots.
% The gnuplot version can suppress the other 3 lines (by specifying just "" for text),
% but the qt version is not that good.
% Compute an 8-sample DFT of the symmetric window DTFT
  H = abs(fft(symmetric8));
  H = fftshift(H);
  H = H/max(H);
  H = 20*log10(H);
  H = max(-dr,H);
  plot(-N/2:(N/2-1), H, "color","red", ".")
  hold on

%------------------------------------------------------------------
% Compute an 8-sample DFT of the periodic window DTFT
  H = abs(real(fft(periodic8)));   % real() is redundant... just to illustrate a point
  H = fftshift(H);
  H = H/max(H);
  H = 20*log10(H);
  H = max(-dr,H);
  plot(-N/2:(N/2-1), H, "color","blue", ".")

%------------------------------------------------------------------
% Compute an 8-sample DFT of the 9-sample symmetric window DTFT
% real() is redundant... just to show that it doesn't mess anything up
  H = abs(real(fft(periodic_summation)));
  H = fftshift(H);
  H = H/max(H);
  H = 20*log10(H);
  H = max(-dr,H);
  plot(-N/2:(N/2-1), H, "color","green", ".")

%------------------------------------------------------------------
#{
h = legend(['PG=' num2str(PG_symmetric8,'%5.4f') ', L = 8'],...
           ['PG=' num2str(PG_periodic8, '%5.4f') ', L=9-1 =8 (truncated)'],...
           ['PG=' num2str(PG_symmetric9,'%5.4f') ', L=9-1 =8 (added)'],...
           "location","south");
  set(h, "fontsize",10+d)
% legend boxoff
#}
%------------------------------------------------------------------
% Connect the dots
% DTFT of symmetric window
  H = abs(fft([symmetric8 zeros(1,M-N)]));
  H = fftshift(H);
  H = H/max(H);
  H = 20*log10(H);
  H = max(-dr,H);
  x = N*[-M/2:M/2-1]/M;

  plot(x, H, "color","red");
  ylim([-dr 0])

% DTFT of periodic window
  H = abs(fft([periodic8 zeros(1,M-N)]));
  H = fftshift(H);
  H = H/max(H);
  H = 20*log10(H);
  H = max(-dr,H);
  plot(x, H, "color","blue");

% DTFT of a 9-sample symmetric window
  H = abs(fft([symmetric9 zeros(1,M-N-1)]));
  H = fftshift(H);
  H = H/max(H);
  H = 20*log10(H);
  H = max(-dr,H);
  plot(x, H, "color","green");

  set(gca,"XTick", -N/2:N/2-1)
  grid on

  ylabel("decibels", "fontsize",12+d)
  xlabel("DFT bins", "fontsize",12+d, "fontweight","bold")
  title('"Spectral leakage" from three Gaussian windows', "fontsize",14+d, "fontweight","normal")

  text(-2.88, -11.66, {"        DTFT";'symmetric8 \rightarrow'}, "color","red",...
        "fontsize",10+d, "fontweight","bold")

% After this call, the gnuplot cursor units change to a normalized ([0,1]) coordinate system
  annotation("textarrow", [.132 .132], [.675 .51],...
        "color", "blue", "string", {"   DTFT";"periodic8"}, "fontsize",10+d,...
        "linewidth",1, "headstyle","vback1", "headlength",5, "headwidth",5)

  annotation("textarrow", [.301 .23], [.437 .437],...
        "color", darkgreen, "string", "DTFT symmetric9", "fontsize",10+d,...
        "linewidth",1, "headstyle","vback1", "headlength",5, "headwidth",5)

  annotation("textarrow", [.301 .197], [.357 .357],...
         "color",darkgreen, "string", "DFT8 (periodic summation)", "fontsize",10+d,...
         "linewidth",1, "headstyle","vback1", "headlength",5, "headwidth",5)

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current20:40, 31 March 2020Thumbnail for version as of 20:40, 31 March 2020652 × 743 (108 KB)Bob K (talk | contribs)Remove legend from 2nd image, because: The equivalent noise bandwidth formula allows values less than one "bin" (for some windows) when used with a 9-point periodic summation and an 8-point DFT. That actually makes sense, because a bandwidth of 1.1 (for instance) measured in 1/9-width bins is only 0.98 measured in 1/8-width bins. But values less than one are not customary.
23:35, 28 January 2020Thumbnail for version as of 23:35, 28 January 2020652 × 743 (116 KB)Bob K (talk | contribs)update for minor code change
14:31, 28 January 2020Thumbnail for version as of 14:31, 28 January 2020652 × 743 (119 KB)Bob K (talk | contribs)minor tweaks
03:48, 28 January 2020Thumbnail for version as of 03:48, 28 January 2020652 × 743 (118 KB)Bob K (talk | contribs)change frame background from white to gray
16:24, 30 September 2019Thumbnail for version as of 16:24, 30 September 2019652 × 743 (96 KB)Bob K (talk | contribs)change a couple of figure labels
05:58, 29 September 2019Thumbnail for version as of 05:58, 29 September 2019652 × 743 (96 KB)Bob K (talk | contribs)fixed code error, and updated image
21:38, 27 September 2019Thumbnail for version as of 21:38, 27 September 2019652 × 754 (101 KB)Bob K (talk | contribs)User created page with UploadWizard

There are no pages that use this file.

Metadata