A.13 Rectangular Integration to Define Normalization Factors for Functions
In several situations a computer is used to obtain points that should represent a continuous function , . Two examples of this situation are the estimation of probability density functions (PDF) via histograms and power spectral density (PSD) estimation via an FFT routine.
Instead of aiming at an analytical expression to represent , the task consists in obtaining a set of points calculated at the values , , which are a uniformly-sampled version of the abscissa .
Often it is possible to first obtain a set of values in which the value is proportional to , i. e., . In this case, it is required to later determine a scaling factor such that the final set of values to represent is obtained via
| (A.29) |
Note that the goal is not necessarily to have . There are situations in which the set of points must obey a property. For example, when histograms are used to estimate probability mass functions, one desired property is that . Alternatively, the goal may be to scale the histogram such that the two resulting curves (normalized histogram and probability density function) coincide. The values of are different for these two possible cases of histogram normalization as discussed after recalling the rectangle method.
The rectangle method [ urlBMrec] is used for approximating a definite integral:
| (A.30) |
where is the rectangle width and .
The rectangle method can be used, for instance, to relate the continuous-time convolution in Eq. (3.2) with its discrete-time counterpart in Eq. (3.1). Assuming is the sampling interval used to obtain the discrete-time signals and from and , respectively, the factor is required to better approximate the samples of when using a discrete-time convolution:
| (A.31) |
Besides, rectangle integration is useful to calculate the scaling factor in the two cases discussed in next section.
A.13.1 Two normalizations for the histogram
When the task is to estimate the PDF of a continuous random variable, one can try using a discrete histogram , which is obtained by drawing values from and counting the number of values occurring at each of bins. Intuitively, for large and , the curve (or the “envelope”) of the histogram resembles but it is off by a normalization factor .
If is chosen, which is the most adopted option, one has and, consequently . However, in this case, may be far from by a large scaling factor. This can be observed in the curves generated by the following code:
1M=1000; x=3*rand(1,M); %M random numbers from 0 to 3 2B=100; [hatgx,N_x]=hist(x,B); %histogram with B bins 3hatfx = hatgx/M; %normalize the histogram to sum up to 1 4plot(N_x,hatfx,[-1,0,0,3,3,4],[0,0,1/3,1/3,0,0],'o-') 5xlabel('random variable x'), ylabel('PDF f(x)') 6legend('estimated','theoretical'); sum(hatfx)
The result of sum(hatfx) is equal to one, as specified, but the PDF of the simulated distribution is 1/3 over its support and the superimposed estimated and theoretical graphs do not match. This discrepancy between the curves should be expected given that the normalized histogram hatfx was in fact an estimate of a probability mass function (PMF) of a discrete random variable, obtained by quantizing the original . Another normalization factor must be used if the goal is to have .
To obtain such that , one can use the property that the integral of a PDF is one. Based on the rectangle method one can write
where . Because , one obtains , which is the original factor divided by the bin width . The function ak_normalize_histogram.m uses this approach. Using the same example of the previous code, the following commands for obtaining hatfx would lead to consistent theoretical and estimated curves:
1M=1000; x=3*rand(1,M); %M random numbers from 0 to 3 2B=100; [hatgx,N_x]=hist(x,B); %histogram with B bins 3h=3/B; %h is the bin width assuming the support is 3 4hatfx = hatgx/(M*h); %PDF values via normalized histogram 5plot(N_x,hatfx,[-1,0,0,3,3,4],[0,0,1/3,1/3,0,0],'o-') 6xlabel('random variable x'), ylabel('PDF f(x)') 7legend('estimated','theoretical'); sum(hatfx)
As expected, in contrast to the sum equal to one in the first code, in this case sum(hatfx)=1/h=33.3. Both histogram normalization factors, and , are useful and the choice depends whether the application requires values from a PMF or PDF, respectively.
A.13.2 Two normalizations for power distribution using FFT
Another application that can be related to Eq. (A.21) is the use of FFT for estimating how the signal power is distributed over frequency. It is assumed here a finite-duration discrete-time signal with non-zero samples.
The squared FFT magnitude plays the role of the function in Eq. (A.29). The choice leads to an estimate of the mean-square spectrum (MSS) of Eq. (4.33), while corresponds to PSD in Eq. (4.21), where and is given in Hz. As indicated in Table A.1, the two options for have similarities with the ones for histogram normalization.
is histogram | is | |
Estimate a discrete
function | ||
is PMF (probability) | is MSS (Watts) | |
Estimate a
continuous
function | ||
is PDF (likelihood) | is PSD (watts/Hz) | |
In both cases in Table A.1, when going from a discrete to a continuous function, the bin width ( for histogram and for the FFT), is used as normalization factor.