Has any one seen this window function?

Started by Cedron 4 years ago15 replieslatest reply 1 year ago307 views
Here is the definition:

\( w[n] = 4 \sin \left( \frac{n}{N}\pi \right) \sin \left( \frac{n+1}{N}\pi \right) \)

It's special, because it ensures that

$$ w[0] =  w[N-1] = 0 $$

And it centers the window function on the samples (end to end) rather than the frame.

The derivation can be found here:

Why could window function help to get more accurate specific frequency amplitude?

I can't match it to any in the classic harris paper:

"On the Use of Windows for Harmonic Analysis with the Discrete Fourier Transform. FREDRIC J. HARRIS"

or here:


Did I miss it as a special case of one of the parameterized equations?

Of course, the Sine terms could also be raised to powers for a wider stance on the DFT.

Do any of the windows experts in the house care to give it an objective independent evaluation, ala the wiki treatment?

Thanks in advance.
[ - ]
Reply by rbjFebruary 17, 2023

maybe you could float this at the dsp.stackexchange

[ - ]
Reply by CedronFebruary 17, 2023

Follow the link, it sort of is.  I wanted a more slow paced, discussion oriented forum.

[ - ]
Reply by kazFebruary 17, 2023

it looks same (or very close) as hanning window scaled by 4

[ - ]
Reply by CedronFebruary 17, 2023

It is, very close.  I would call it the Discrete VonHann (I consider the term hanning erroneous even if it is commonly used).

$$ \lim_{N \to \infty} w[n] = VonHann[n] $$

The scaling factor popped out of the derivation and I left it as it is immaterial.

It isn't new to me, implicit in my frequency formula.

[ - ]
Reply by kazFebruary 17, 2023

And I assume any vector that goes up then comes down is defined as window but it needs a name. The only difference is the boxcar window which is not a window!!

[ - ]
Reply by CedronFebruary 17, 2023
Agreed about the boxcar window not being a window.

If this window function is "new", then the best name IMO, as I mentioned, is "The Discrete VonHann". 

Follow the derivation link at top.  I framed it as a weighted average of DFT bins with a weighting of:

$$ ( -e^{i\omega}, e^{i\omega}+ e^{-i\omega},-e^{-i\omega} ) $$

and that is the window function when

$$ \omega = \frac{2\pi}{N} $$

The window function family can also be expressed in this near VonHonn form:

$$ \cos ( \omega) - \cos \left( \frac{n}{N}2\pi + \omega \right) $$

I'll whip up some numbers but I wanted nice charts and official numbers.

[ - ]
Reply by Rick LyonsFebruary 17, 2023

Hi kaz. Whether or not a boxcar (rectanglar) sequence is a window depends on your definition of the word "window".

[ - ]
Reply by CedronFebruary 17, 2023
I think the whole window thing is easily understood from a definitional basis.

Compare how the (1/N) DFT is related to its continuous counter parts, the FT and DTFT, are defined on the same interval.

The DFT:

\( \frac{1}{N} \sum_{n=0}^{N-1} x[n] e^{-i\frac{2\pi}{N}kn} \)

The FT:

\( \int_{-\infty}^{\infty} w(t) x(t) e^{-i2\pi t f } dt \)


\( \frac{1}{N} \sum_{n=-\infty}^{\infty} w[n] x[n] e^{-i\omega n} \)

\( \omega = \frac{k}{N}2\pi \)

Where the window functions are, and their respective required nature, should be obvious to the eye.
[ - ]
Reply by Rick LyonsFebruary 17, 2023

Hi Cedron. I've not seen that w[n] window sequence before. It's frequency-domain behavior is super-similar to the Von Hann (hanning) window if we ignoring w[n]'s zero Hz gain factor. My guess is, in practice there will be very little difference between using your w[n] window compared to using a Von Hann window.

[ - ]
Reply by CedronFebruary 17, 2023
Hi Rick, thanks for your reply.  

For any N more than fingers and a few toes, I totally agree, no functional difference beyond a gnat hair.  This is more of a theoretical thing.

Perhaps, "The Discrete VonHann" is too strong of a claim.  The VonHonn is at the base of a lot of families.

It is derived, not contrived.  Natural so to speak.

I am now thinking "Dipped and Shifted Von Hann" as that quite matches the cosine version.  Thus, DSVH is my working acronym.

The most concise behavior description I can come up with is "The VonHann is slightly lowered and shifted by a half sample so $w[0]=w[N-1]=0$.  This also shifts the peak of the window function one half sample to the mean of the endpoints not the center of the frame."

So, centered on the samples instead of centered on the frame, yet still a genuine VonHann.  (My rescaling is still arbitrary at this point.)

Here's a comparison of the two window functions for some fairly small N.


      VonHann     DSVH

  0   0.00000     0.00000
  1   0.00722     0.01385
  2   0.02657     0.03714
  3   0.05192     0.06250
  4   0.07522     0.08185
  5   0.08907     0.08907
  6   0.08907     0.08185
  7   0.07522     0.06250
  8   0.05192     0.03714
  9   0.02657     0.01385
 10   0.00722     0.00000

  0   0.00000     0.00000
  1   0.00558     0.01078
  2   0.02083     0.02946
  3   0.04167     0.05103
  4   0.06250     0.06971
  5   0.07775     0.08049
  6   0.08333     0.08049
  7   0.07775     0.06971
  8   0.06250     0.05103
  9   0.04167     0.02946
 10   0.02083     0.01078
 11   0.00558     0.00000

A more formal analysis on the differences at low N might be more interesting to some one besides me.

Here's some starter code for those who want to to get started.

#---- Build the VonHann Windows

        theNormed  = np.zeros( N )
        theVonHann = np.zeros( N )
        theDSVH    = np.zeros( N )

        for n in range( N ):
          theNormed[n] = RN

          theVonHann[n] = 0.5 * ( 1.0  - np.cos( theBeta * n ) )\
                        * RN

          theDSVH[n]  = np.sin (   n       * theBeta * 0.5 ) \
                      * np.sin ( ( n + 1 ) * theBeta * 0.5 ) \
                      * RN

          theDSVH2 = ( np.cos( theBeta * 0.5 )           \
                     - np.cos( theBeta * ( n + 0.5 ) ) ) \
                   * 0.5 * RN

          print( "%3d  %8.5f    %8.5f    %8.5f" % \
                 ( n, theVonHann[n], theDSVH[n], theDSVH2 ) )

I'm studying it more, works well in the math.  I'll be putting that in a blog article and adding a link here (or not... for a while).

(All: I'm holding off any spoiliers I find, and if you have any of your own, please post only links here with a whispy description for those who wish to follow after taking a stab at it on their own.)


[ - ]
Reply by CedronFebruary 17, 2023

Okay, there was indeed a prize at the end of this search.  If you want to find out what it is, follow this link to my latest article:

[Spoiler protected Title]

A huge trophy.

[ - ]
Reply by engineer68February 17, 2023

The point about that function is that it can effectively be integrated into DSPs and FPGAs, since one needs only N+1 calculations and can use the values twice. For FPGAs e.g. this is very suitable to use a value registered once almost without additional storage and loss of time.

For small windows were one desires to make use of all data I use (N+1) values for the window and leave away the first and the last to shun the zeros.

[ - ]
Reply by kazFebruary 17, 2023

Two windows, one is (n) points, the other (n) points, both symmetrical. both need to be represented on (N) bits.

So how on earth one fits the fpga better.

You have been spamming all over DSP/FPGA/blog posts in a matter of one hour resurrecting some ten or so ancient threads. 

I hope the Forum will not allow such noise.

[ - ]
Reply by CedronFebruary 17, 2023
I don't know.  I kind of appreciate old posts being read.

The topic of FPGAs is kind of unfamiliar ground to me, so I didn't make a response, as there didn't really seem to be a request for one, nor did I have a lot to say.

What is special about this window is that it is a member of a family of windows that contain the primary Eigenvectors of the DFT.  They are essentially Gaussian, but the discrete versions are an approximation to the continuous versions.  There is a wide DFT frame for a very small effective frame, theoretically making it better for close frequency resolution.

Testing that is on my back burner.  Anybody is welcome to beat me to it.

If our new poster has something to add or question, perhaps a new post with an embedded link to the original question would be a more palatable choice for some.
[ - ]
Reply by kazFebruary 17, 2023

I was comparing your window with Hann window.

for same size window, same bit resolution and close formulas I don't understand what the new poster is adding:

your window equation: w(n) = 4*sin(n*pi/N).sin((n+1)*pi/N)

Hann: w(n) = 0.5*(1 − cos(2*pi*n*N)) 

so if we want to implement it on fpga we either go for LUT or runtime compute from the equations. In either case I got no idea why one fits FPGA better than the other. or uses less resource or latency.

I am not against contributing to any post but this poster has suddenly posted onto ten old threads in one single hour.