/* The gaussian(x) = (exp(-48*((i-(n+1)/2)/(n+1))^2)-exp(-12))/(1-exp(-12)); For power we need thearea under the square of this window: Integrate (gaussian(i)^2,i=1..n) = (sqrt(Pi)*sqrt(3)*sqrt(2)*erf(2*(n-1)*sqrt(3)*sqrt(2)/(n+1))*(n+1)+ 24*exp(-24)*(n-1)+ -4*sqrt(Pi)*sqrt(3)*exp(-12)*erf(2*(n-1)*sqrt(3)/(n+1))*(n+1))/ (24 * (-1+exp(-12))^2) To compare with the rectangular window we need to divide this by the window width (n-1) x 1^2. */ static double gaussian_window_squared_correction (long n) { double e12 = exp (-12), denum = (e12 - 1) * (e12 - 1) * 24 * (n - 1); double sqrt3 = sqrt (3), sqrt2 = sqrt (2), sqrtpi = sqrt (NUMpi); double arg1 = 2 * sqrt3 * (n - 1) / (n + 1), arg2 = arg1 * sqrt2; double p2 = sqrtpi * sqrt3 * sqrt2 * (1 - NUMerfcc (arg2)) * (n + 1); double p1 = 4 * sqrtpi * sqrt3 * e12 * (1 - NUMerfcc (arg1)) * (n + 1); return (p2 - p1 + 24 * (n - 1) * e12 * e12) / denum; }
/* The gaussian(x) = (exp(-48*((i-(n+1)/2)/(n+1))^2)-exp(-12))/(1-exp(-12)); For power we need the area under the square of this window: Integrate (gaussian(i)^2,i=1..n) = (sqrt(Pi)*sqrt(3)*sqrt(2)*erf(2*(n-1)*sqrt(3)*sqrt(2)/(n+1))*(n+1) + 24*exp(-24)*(n-1)+ -4*sqrt(Pi)*sqrt(3)*exp(-12)*erf(2*(n-1)*sqrt(3)/(n+1))*(n+1))/ (24 * (-1+exp(-12))^2), where erf(x) = 1 - erfc(x) and n is the windowLength in samples. To compare with the rectangular window we need to divide this by the window width (n -1) x 1^2. */ static void _Spectrogram_windowCorrection (Spectrogram me, long numberOfSamples_window) { double windowFactor = 1; if (numberOfSamples_window > 1) { double e12 = exp (-12); double denum = (e12 - 1) * (e12 - 1) * 24 * (numberOfSamples_window - 1); double arg1 = 2 * NUMsqrt3 * (numberOfSamples_window - 1) / (numberOfSamples_window + 1); double arg2 = arg1 * NUMsqrt2; double p2 = NUMsqrtpi * NUMsqrt3 * NUMsqrt2 * (1 - NUMerfcc (arg2)) * (numberOfSamples_window + 1); double p1 = 4 * NUMsqrtpi * NUMsqrt3 * e12 * (1 - NUMerfcc (arg1)) * (numberOfSamples_window + 1); windowFactor = (p2 - p1 + 24 * (numberOfSamples_window - 1) * e12 * e12) / denum; } for (long i = 1; i <= my ny; i++) { for (long j = 1; j <= my nx; j++) { my z[i][j] /= windowFactor; } } }