0
$\begingroup$

I am looking at implementing different window functions in an application I am making. I have found the formulas for all major symmetrical windows, however I would like to implement half windows.

This may be a stupid question, but does the window literally jump straight from 0 to 1? or is there a small curvature to the start. ie, do I use the symmetrical formula and just use the second half? Or are there specific formulas for calculating half windows?

$\endgroup$
  • $\begingroup$ Do you have a reference to half windows, or what motivates you to implement them? $\endgroup$ – Olli Niemitalo Aug 7 at 18:17
0
$\begingroup$

Let us start with an example relying on a simple time-warp, based on the Hann window (code below). It consists in modifying time index $t\in [-1,1]$, here with function $t\mapsto 2 (t+1)^\alpha/2^\alpha-1$. There are many other ways.

Symmetric and asymmetric Hann windows

Asymmetrical windows, or non-symmetric windows, are a topic of interest, albeit somewhat marginally used. I have not seen a lot on literature on this topic. It however has been discussed here at SE.DSP in:

They can be useful when the data is itself non-symmetric or skewed, when the processing requires symmetry imbalance, or when you have no other choice. Discrete finite-support dyadic wavelets fall into the latter and third category. Real-time analysis, or causal imbalance, are common for the second case. Exponentially weighted windows are an example, see What is the name of this digital low pass filter? or What is the name of these simple filter algorithms?. In the first case, you can find cases in analytical chemistry (chromatography), with trailing peaks or band broadening, in audio processing or spectral analysis.

Options to create asymmetric window functions are described as follows:

0 - Zero: the exponential window, used in the "exponentially-weighted moving average filter" (EWMA, see Is there a technical term for this simple method of smoothing out a signal?)

1 - First, for "real-time" applications that can be bufferized, or offline needs, you can first perform an extension trick. It is common to preserve a little data before the time sample when you actually need the data. This happens with triggered frame acquisition: you start acquiring "useful data" after a threshold is crossed, but your have a custom buffer for the data before. Hence, you can extend the data frame buffer "to the left", with real data, or by symmetry, and then you can use longer (and more classical) windows (symmetric or not), so that they take off when your signal is not interesting, and "start" where you want to analyze.

2 - Second: for many models, you can combine a "left-sided window" with a certain up-rate, to a "right-sided window" with another down-rate. This can seem ad-hoc, but is in use in chemistry, for the shape of skewed peaks (two halves of a Gaussian for instance). The junction should be consistent. In What is the meaning of half window functions?, the window is non-continuous. In many applications, one often tries to have regular functions (continuous, differentiable). For discrete windows, one often choose that $w_l(0-)\approx w_r(0+)$, which is easily done on isotonic (increasing/decreasing) windows with $[0,1]$ normalization. Higher orders of regularization could be enfored as well.

3 - Third: you can build a closed-form skewed function. A lot of skewed probability distribution functions can be used (log-normal, beta, Weibull) as windows.

4 - Fourth: you can distort or warp the time axis of a symmetric window, to yield an asymmetric one.

Some references:

Matlab code:

% Laurent Duval
% 2019/08/06
% SeDsp59829
close all;clear all
nSample = 65;
timeUniform = linspace(-1,1,nSample);
powerExp = 0.5;
timeWarpPower = 2*((timeUniform+1).^powerExp)/2^powerExp-1;
hannWindow = @(time) 1/2*(1+cos(pi*time));

hannWindowUniform = hannWindow(timeUniform);
hannWarpPower = hannWindow(timeWarpPower);
figure(1);clf;hold on
plot(timeUniform,hannWindowUniform, 'ob')
plot(timeUniform,hannWarpPower, 'gx')
grid on
$\endgroup$
1
$\begingroup$

A use of such window functions would be to window data that "goes straight to business" starting at the first sample and then gradually dies off, like an impulse response of some system. See What is the meaning of half window functions? A smooth rise in the window function would be detrimental as it would attenuate the important peak, unless the rise in the window is quick enough and the peak delayed enough. However, I think it would be a stretch to call something like that a half-window, if it is not a half of some window. So start directly at 1 at the peak of a symmetrical window I think.

Then again, beware that a sine window a.k.a. cosine window may also be called half-sine window or half-cosine window, as it represents half a cycle of a sinusoid (sine or cosine).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.