From Fourier to spectral density
In the previous articles I studied a sine wave buried in noise and then calculated the intrinsic noise of electronic components. But if I look at a sequence of voltages with a digital oscilloscope, how can I tell how much of the signal lies at a particular frequency? And above all, how can I compare a spectrum obtained from a finite number of samples with a noise density expressed in nV/√Hz?
I start from the simplest case, a sine wave with no noise, to check the normalization of the transform before tackling noise spectra. I use GX-TXT DEV112 P012, with the previous micropatches, and the Scientific Worksheet. These are not yet bench measurements.
1. From time to discrete frequencies
I consider N samples xn of a real signal, spaced by Δt = 1/fs. I can represent them as a combination of complex exponentials that are orthogonal over the N positions. With the convention of an unnormalized forward transform, the coefficients are
\[ X_k = \sum_{n=0}^{N-1} x_n\, e^{-i 2\pi k n/N}, \qquad k = 0,\dots,N-1. \]
Orthogonality follows from the sum of a geometric progression: for integers k and l between 0 and N−1, the sum of exp[i2π(k−l)n/N] is N when k=l and zero otherwise. Multiplying by the complex conjugate of the basis function and summing I obtain the previous formula; inverting the combination I get
\[ x_n = \frac{1}{N}\sum_{k=0}^{N-1} X_k\, e^{i 2\pi k n/N}. \]
The FFT is an algorithm for evaluating the DFT, not a different physical transform. The bins are spaced by Δf = fs/N = 1/T, with T = N/fs. For a real signal XN−k = Xk*. In FFT order, for even N, the bins k = 0,…,N/2 represent the frequencies from zero to Nyquist; the following ones represent the negative frequencies fk = (k−N)Δf. The Nyquist bin has no distinct second partner. I will not confuse the mathematical index k, which starts at zero, with the row of the sheet, which starts at one.
Try it yourself with GX-TXT
I carried out the experiments that follow with GX-TXT, free software you can install on Linux. There is no need to take my numbers on trust: follow the steps, rebuild the signals and spectra and compare your results with mine. Then change something — the frequency of the sine wave, the number of samples, the window — and see how the bins and the leakage shift. It is the best way to really understand what a spectrum shows, and to have some fun too.
2. A sine wave that occupies exactly one positive bin
I create the session LockIn_04_fourier_densita_spettrale and open the Worksheet. In Functions (1) I choose numeric.uniform_grid (2): start = 0, stop = 0.0995, spacing = 200, Options = mode="count" (3). I press Preview fields (4), wait for the results to be captured, choose x and destination A1 (5), then Apply result (6). The 200 samples have a step of 0.5 ms; T = 0.1 s.

I choose signal.generate.sine (7), set time = A1:A200, frequency = 200, modulation = empty(), Options = amplitude=1 phase_rad=0 (8). After Preview fields I select value_real and B1 (9), then Apply result (10). I interpret B in mV. The sine wave completes 20 periods in the 100 ms window: the positive bin is k = 20, i.e. f = 200 Hz.

In Functions I select numeric.fft (11). I enter values = B1:B200, Options = nfft=200 normalization="backward" (12). I press Preview fields (13). I choose the real field, destination C1, and apply the result; then I select imaginary, destination D1 (14), and apply this field too (15). I wait for each operation before the next.

The forward DFT is not normalized
For xn = A sin(2πk0n/N) the transform contains two coefficients: Xk0 = −iNA/2 and XN−k0 = +iNA/2. With N=200 and A=1 mV I therefore expect −100i at bin 20 and +100i at bin 180. Row 21 of the Worksheet shows −100 in column D; the small real terms are rounding residues. I must not read 100 mV as the amplitude of the sine wave: the forward DFT is still unnormalized.
3. I check Parseval
Thanks to the orthogonality of the exponentials, substituting the inverse transform into Σ|xn|² cancels the terms with different indices. With the backward convention I obtain
\[ \sum_n |x_n|^2 = \frac{1}{N}\sum_k |X_k|^2, \qquad \mathrm{RMS}^2 = \frac{1}{N^2}\sum_k |X_k|^2. \]
The mean square value in mV² is a squared voltage, not yet a power in watts: for a resistive load I would have to divide it by R. I use all 200 components of the transform, including the negative ones. In Cell & Formula, via Go to, I set the following formulas.
| Cell | Formula | Meaning |
|---|---|---|
| E1 | =numeric.add(numeric.multiply(C1:C200,C1:C200),numeric.multiply(D1:D200,D1:D200)) | |X|² (mV²) |
| F1 | =numeric.multiply(A1:A101,20000) | Positive axis 0–1000 Hz, 10 Hz step; the numerical factor is fs²/N. |
| G1 | =numeric.sqrt(E1:E101) | Raw magnitude of the 101 non-negative bins (mV). |
| H1 | =vector(numeric.rms(B1:B200),numeric.mean(numeric.multiply(B1:B200,B1:B200)),numeric.sum(E1:E200)/40000,numeric.mean(numeric.multiply(B1:B200,B1:B200))-numeric.sum(E1:E200)/40000) | Four checks, in H1:H4. |
In Figure 4 I select H1 with Go to (16), enter the formula (17) and use Apply (18). The sheet shows the results (19).

| Quantity | Calculated value |
|---|---|
| Time-domain RMS | 0.70710678 mV |
| Time-domain mean square value | 0.5 mV² |
| Mean square value from the FFT | 0.5 mV² |
| Difference time − FFT | −5.5511151 × 10−17 mV² |
The mean square value of a sine wave of amplitude A is A²/2. The comparison confirms the normalization in this case, within numerical rounding. For a forward or unitary FFT the factors in Parseval’s relation would change.
The graph of the raw FFT
I select F1:G5, open Chart (20) and use Add selection (21). I set X column = F, Y columns = G, First row = 1, Last row = 101 (22), Kind = bar (23), title FFT magnitude (mV) versus frequency (Hz). I use Apply (24) and enlarge the chart area by dragging the panel divider. I wait for the actual rendering.

This graph does not yet represent either the normalized one-sided amplitude spectrum or a spectral density. To obtain the former, for the inner positive frequencies I will have to multiply the magnitude by 2/N, and for DC and Nyquist by 1/N. For the PSD, instead, I will have to normalize the squared magnitude with respect to the sampling frequency and the window, handling the power of the conjugate bins correctly. That will be the next check.
I keep the spectrum in the session
Procedure in GX-TXT: publishing and plotting the FFT (Figures 6–9b)
From the Worksheet Chart I use Publish immutable Graph to Plots (26). The Dataset of the 101 non-negative bins is stored; in this version you have to wait for Dataset operations to actually finish. In my case a busy warning appears while the graph is being registered. I do not repeat the publication: I check that the Dataset is already available.

To get a graph with explicit titles and units, I use Analysis → Scientific Dataset Plot. As the source I select the already published Dataset worksheet_chart_1796051847677233 (28; the identifier is assigned automatically), enable Scientific dataset 2D and open Series… . I set X = x, Y = y1 (29), ID fft_magnitude, Label Raw FFT magnitude and Representation = bar (30). I confirm with Add/update one series (31).

In Configure… I set the title Raw FFT magnitude – coherent sine, X = Frequency (Hz), Y = FFT magnitude (mV) (32). In Axes… (33) I choose linear scales, grid both and automatic limits. I save the session configuration with Sessions → Session → Save configuration, then run Run enabled analyses from the Run tab. The first Run had already generated the base PNG, but could not render the variant not yet saved in the manifest; after the explicit save, the new Run ends with PASS. I do not modify the Dataset.

In Plots (34) I select the base graph (35), which is now available together with the Worksheet variant.

Looking at the first bar representation I notice that almost the whole graph seems empty. I do not want the small coefficients to disappear from view: I reopen Series… and add a second representation of the same data, without creating a new Dataset. I keep X = x and Y = y1; I give the new series ID fft_bins (74), Label DFT bins - 10 Hz spacing and Representation = scatter (75). I confirm with Add/update one series (76) and move the series after the bar with Down (77), so the markers are visible even on top of the peak.

I reopen Configure… → Axes… and replace the automatic limits with values chosen for this experiment: in the X row (78) I set Min = 0, Max = 1000 and Step = 100 Hz, i.e. from the origin to the Nyquist frequency; in the Y Left row (79) I set Min = −5, Max = 120 and Step = 20 mV. The small margin below zero only serves to avoid hiding the markers on the axis: the FFT magnitude cannot be negative. I press Save and rerender plot (80) and save the session configuration.


Why do I see only one bar?
The orange circles along the zero line are FFT results too, not missing points. With 200 samples at 2000 Hz I observe a duration of 0.1 s, corresponding to exactly 20 periods of the 200 Hz sine wave. The spacing between the analysed frequencies is Δf = fs/N = 10 Hz: the sine wave coincides exactly with bin k = 20. Because of the orthogonality of the DFT sinusoids, in the ideal case it does not contribute to the other bins. The second component, at −200 Hz, is present in the full FFT but not in this representation of the non-negative frequencies only.
To understand what “practically zero” means, I read some values of the Dataset around the peak directly:
| Bin k | Frequency (Hz) | Raw magnitude (mV) |
|---|---|---|
| 18 | 180 | 8.53 × 10−14 |
| 19 | 190 | 2.21 × 10−13 |
| 20 | 200 | 100 |
| 21 | 210 | 2.25 × 10−13 |
| 22 | 220 | 8.82 × 10−14 |
The tiny non-zero values are compatible with the numerical errors in generating and transforming the synthetic signal; they do not represent measured physical noise. The width of the bar is a graphical choice, not the bandwidth of the tone. The 100 mV is the magnitude of the unnormalized FFT, not the physical amplitude of 1 mV. What happens, instead, when the signal does not coincide with one of the bins? We will see later by moving the frequency to 205 Hz: its energy will spread over several bins, making spectral leakage visible.
4. From the raw magnitude to the one-sided spectrum
I reopen the saved Worksheet. For a real signal the negative part of the transform is the complex conjugate of the positive part. I want to keep the bins from k=0 to k=N/2, including the end points. I call ck the factor that is 1 at DC and Nyquist and 2 for the inner bins. For odd N there is no Nyquist bin and I also double the last positive bin.
In Functions I choose numeric.one_sided (36), enter real = C1:C200, imaginary = D1:D200 (37) and Options = scaling="amplitude" (38). I press Preview fields, select factor (39), destination I1 and Apply result. The field contains the 101 factors ck, not the already normalized magnitude. I check that the operation has finished before entering other formulas.

With the backward FFT convention, the amplitude spectrum in terms of the peak amplitude of the coherent sine wave is
\[ A_k = \frac{c_k |X_k|}{N}\quad [\mathrm{mV}]. \]
This value is not the amplitude spectral density (ASD), whose unit is mV/√Hz. To obtain the power spectral density (PSD) with a rectangular window, I use Parseval’s relation and divide the contribution of each bin by Δf:
\[ \mathrm{PSD}_k = \frac{c_k |X_k|^2}{N f_s}\quad [\mathrm{mV^2/Hz}]. \]
The factor 2 in the PSD
For the inner bins the factor 2 appears only once in the PSD: I am adding the powers of the two conjugate components, not squaring the amplitude correction factor. The ASD is √PSD, in mV/√Hz. For a coherent sine wave with a rectangular window, in the inner bins PSDk = Ak²/(2Δf). For DC and Nyquist the factor 2 in the denominator does not appear.
Calculation in the Worksheet
I use Go to and Cell & Formula, leaving the previous columns untouched. In J1, K1 and L1 I enter, in order:
| Cell | Formula | Unit |
|---|---|---|
| J1 | =numeric.multiply(numeric.multiply(G1:G101,I1:I101),1/200) | mV (peak amplitude) |
| K1 | =numeric.multiply(numeric.multiply(E1:E101,I1:I101),1/400000) | mV²/Hz |
| L1 | =numeric.sqrt(K1:K101) | mV/√Hz |
To check the quantities I select M1 (40) and enter the formula (41), which collects the end points of the factor vector, the values at bin 20 and the sum of the PSD multiplied by Δf, compared with H2. I press Apply (42).
=vector(I1,I21,I101,J21,K21,L21,10*numeric.sum(K1:K101),H2-10*numeric.sum(K1:K101))

| Check | Value |
|---|---|
| c at 0, 200 and 1000 Hz | 1; 2; 1 |
| A at 200 Hz | 1 mV |
| PSD at 200 Hz | 0.05 mV²/Hz |
| ASD at 200 Hz | 0.2236068 mV/√Hz |
| Sum of PSD × Δf, over all 101 bins | 0.5 mV² |
| Time-domain mean square value − discrete integral | −5.5511151 × 10−17 mV² |
I use a rectangular sum of the bin contributions, not a trapezoidal rule that would halve DC and Nyquist again. The integrated PSD preserves the mean square value. The PSD value of a coherent spectral line depends on the record length, so the peak value of the PSD or ASD of a sine wave must not be compared directly with the density of a white noise.
Check with the native periodogram
So as not to limit myself to comparing formulas that all start from the same FFT result, I call the guided operation numeric.signal_periodogram (44). In this case I use B1:B200 directly, sample_rate = 2000 (45), Options = nfft=200 window=empty() (46). I specify the empty window explicitly: in the P012 provider it is equivalent to the rectangular window of N unit coefficients. Omitting the parameter is not equivalent, because the default choice is Hamming. After Preview fields I choose psd_real and destination N1 (47), then Apply result (48).

The PSD of the periodogram is stored in column N. The first visible values coincide with those calculated in column K to the precision shown. For the quantitative comparison I calculate the maximum and the sum of the bins separately, as I show below.
Micropatch MP007 for the P012 Worksheet
To repeat the reading of the spectral tables without rebuilding the same projection every time, I use micropatch MP007 (bug 239). The fix reuses the projection already verified, without changing values, units or provenance. With GX-TXT closed, I extract the ZIP and replace plugins/modules/viewer.scientific_worksheet/api/scientific_worksheet_workbook_v2.tcl in the P012 framework directory. I restart GX-TXT. This file already includes MP006: I do not restore the previous file after applying MP007. The first reading still requires the table to be validated; the improvement concerns subsequent readings of the same result. I verified reopening the sheet and the identity of the projections in the spectral case used here.
Checking the peak and the integral of the periodogram
I reopen the Worksheet. In row 21 (49) I check the value of the periodogram N21: 0.050000000000000003. In the same row, K21 (50) contains the PSD obtained with the explicit normalization, F21 the frequency of 200 Hz and J21 the normalized amplitude. The two PSD values coincide to the precision displayed.

I also calculate =numeric.max(N1:N101) in O1 (51) and =numeric.sum(N1:N101) in O2 (52), via Cell & Formula and Apply. I get 0.05 in both cases (53), to the precision displayed. The sum covers all 101 non-negative bins. Multiplying it by the step Δf=10 Hz I obtain 0.5 mV². In the text I interpret the values in mV²/Hz, as expected from the synthetic amplitude chosen in mV.

| Check | PSD derived from the FFT | Native periodogram |
|---|---|---|
| Value at the 200 Hz bin (mV²/Hz) | 0.05 | 0.05 |
| Discrete sum × Δf (mV²) | 0.5 | 0.5 |
I have thus verified, for this coherent sine wave, the agreement of the peak and of the discrete integral of the two results. I do not treat this test as a point-by-point numerical comparison: the initial generator produces values with no declared unit, the PSD built from the formulas has an undeclared unit in the sheet, while the periodogram keeps the unit notation of its own statistical interpretation, (unspecified)^2/Hz. The Worksheet refuses to subtract the two columns. I do not disable the dimensional check and I do not alter the units of the captured results to make the subtraction work. For the following tests I will keep the declaration of physical units separate from the numerical normalization.
5. When the frequency does not coincide with a bin
So far I have deliberately chosen a frequency that occupies one FFT bin. What happens if I move the frequency by only 5 Hz, leaving everything else unchanged? The bin spacing remains 10 Hz; a 205 Hz sine wave falls exactly halfway between 200 and 210 Hz. In the 100 ms record it completes 20.5 periods, instead of the 20 periods of the previous case. The DFT represents the record as a periodic sequence: if the frequency is not coherent with the window length, the content of the sine wave no longer concentrates in a single pair of conjugate bins. This redistribution is called spectral leakage.
I reopen the S04 Worksheet, keep the grid A1:A200 and the previous signal B1:B200. In Functions I select signal.generate.sine (54), with time = A1:A200, frequency = 205, modulation = empty(), Options = amplitude=1 phase_rad=0 (55). After Preview fields I choose value_real and P1 as destination (56), then Apply result (57). The message (58) confirms that the captured result was applied in P1 without changing the source data. The previous graph, still visible, refers to 200 Hz and not to the new sine wave: I keep it as a reference.

5.1. Periodogram with a rectangular window
For the new sine wave I choose numeric.signal_periodogram (59), signal = P1:P200, sample_rate = 2000 (60), Options = nfft=200 window=empty() (61). After Preview fields I choose psd_real, set Q1 as destination (62) and press Apply result. The frequency of bin k is k·10 Hz, in row k+1: in row 21 (63), i.e. 200 Hz, the periodogram is no longer 0.05 but 0.020696643. In row 20 (190 Hz) it is 0.002401646 and in row 19 (180 Hz) 0.00090441695. These contributions far from the actual frequency of 205 Hz make the leakage evident. The lower graph is still the 200 Hz reference, not the graph of column Q.

5.2. Periodic Hann window
A window changes the weighting of the samples before the transform. I use a periodic Hann window of N samples, defined for n = 0,…,N−1 by:
\[ w[n] = 0.5 – 0.5\cos\frac{2\pi n}{N}. \]
In Functions I choose numeric.window (64), name = "hann", length = 200 (65), Options = sampling="periodic" (66). After Preview fields I select values, set S1 (67), press Apply result and wait for completion. Coefficient S101 is 1 (68), as expected for sample n=100. I do not modify P1:P200.

I repeat numeric.signal_periodogram (69) with P1:P200 and sample_rate=2000, setting nfft=200 window=S1:S200 (70). After Preview fields I choose psd_real, destination T1 (71) and Apply result. I compare columns Q (72) and T (73): the frequency and sampling of the signal are identical, only the window changes.

| Frequency (Hz) | Rectangular (mV²/Hz) | Hann (mV²/Hz) |
|---|---|---|
| 220 | 0.0021181934 | 0.00096062867 |
| 230 | 0.00073346587 | 1.9599456 × 10−5 |
| 250 | 0.00021031304 | 4.4927063 × 10−7 |
| 290 | 5.1669115 × 10−5 | 9.1186969 × 10−9 |
The values are those displayed by the Worksheet; the physical units are interpreted from the synthetic amplitude chosen in mV. I have not modified the units of the captured data. The Hann window significantly reduces the contributions far from the tone, but this does not mean it increases the resolution. In general, windows that attenuate the side lobes widen the main lobe. The windowed PSD is normalized with the sum of the squares of the coefficients, not with the square of their sum:
\[ \mathrm{PSD}_k = \frac{c_k\,|\mathrm{DFT}(w\cdot x)_k|^2}{f_s \sum_n w[n]^2}. \]
This explains why I do not interpret a change in the peak of the periodogram as a change in the amplitude of the signal.
5.3. What does the integral of the periodogram preserve?
I return to the reasoning used for Parseval. The DFT of the weighted signal x[n]w[n], normalized as above, must satisfy the relation:
\[ \sum_{k=0}^{N/2} \mathrm{PSD}_k\,\Delta f = \frac{\sum_{n=0}^{N-1} w[n]^2 x[n]^2}{\sum_{n=0}^{N-1} w[n]^2}. \]
For the rectangular window, w[n]=1 and I recover the mean of the squared samples. For the Hann window, instead, I obtain a weighted mean square: I cannot claim that the two are equal for every signal. In this particular experiment, the 205 Hz frequency corresponds to 20.5 periods and the square of the sine wave contains a component at 410 Hz, i.e. exactly bin 41. The square of the periodic Hann window contains only the DC, k=1 and k=2 components (and their conjugates); their orthogonality to bin 41 leads to a predicted integral of 0.5 mV² for both windows.
To compare leakage quantitatively I choose a common reference band that includes the bins at 190, 200, 210 and 220 Hz, i.e. rows 20–23 of columns Q and T. The quantity to integrate outside this band is the sum over the bins from 0 to 180 Hz and from 230 to 1000 Hz, multiplied by Δf=10 Hz. Dividing by the total integral I obtain the out-of-band fraction. This definition is a choice made for the experiment, not a universal property of the window.
In this first attempt the Worksheet refuses the arithmetic operation on the PSDs in Q and T: the synthetic voltage had been generated with no declared unit and the periodogram returned the expression (unspecified)^2/Hz, which the formulas do not recognize. The value of 0.5 mV² is therefore, at this point, a theoretical prediction. The check with physical units is carried out in section 5.7. To complete it, the unit of the input voltage must be declared correctly and the periodograms recalculated, keeping the original results.
The following check revealed a limitation of the version used: declaring the unit of a column does not change that of the generated samples. In addition, the vector product of the normalized sine wave by an amplitude declared in mV loses the dimensional information, while the scalar product keeps the physical unit. For this reason I do not assign units artificially to the curves already calculated: the integration with consistent units will be repeated in sections 5.6 and 5.7.
5.4. How much noise does the window let through?
The Hann window attenuates the side lobes, but looking only at the bin spacing is not enough to predict the response to noise. I imagine observing a single DFT bin as a filter: the window determines its response to nearby frequencies. I normalize the gain of the filter to the centre frequency and compare the area of its power response with that of a rectangular filter of unit gain. In this way I obtain the equivalent noise bandwidth (ENBW):
\[ B_{\mathrm{ENBW}} = f_s \frac{\sum_n w[n]^2}{\left(\sum_n w[n]\right)^2}. \]
The formula follows from Parseval applied to the window coefficients: the integral of the power response over a frequency interval of length fs is fsΣw[n]²; the square of the gain at the centre is (Σw[n])². Dividing gives a bandwidth in Hz. For the rectangular window the two sums are N and N: BENBW=fs/N=10 Hz. For the periodic Hann window the two sums are N/2 and 3N/8: BENBW=1.5 fs/N=15 Hz.
I want to check the second result using the 200 Hann coefficients already generated in S1:S200. With Go to (81) I choose V1, in Cell & Formula (82) I enter the following formula and press Apply (83):
=vector(numeric.sum(S1:S200),numeric.sum(numeric.multiply(S1:S200,S1:S200)),2000*numeric.sum(numeric.multiply(S1:S200,S1:S200))/(numeric.sum(S1:S200)*numeric.sum(S1:S200)))

| Quantity | Rectangular (theory) | Hann (Worksheet) |
|---|---|---|
| Σw[n] | 200 | 100 |
| Σw[n]² | 200 | 75 |
| BENBW | 10 Hz | 15 Hz |
| BENBW/Δf | 1 | 1.5 |
Leakage versus noise bandwidth
The result confirms that the Hann window widens the equivalent bandwidth by 50% compared with the rectangular one: for the same white spectral density and normalized centre gain, the noise power collected by a bin increases by a factor of 1.5. This does not contradict the reduction of the side lobes; it is precisely the trade-off between rejection of distant frequencies and noise bandwidth around the tone. I do not confuse this ENBW of the analysis window with that of the output filter of a lock-in: the physical concept is the same, but the transfer functions are different.
5.5. Two representations of the same leakage
The table of point values does not yet let me see how the phenomenon is distributed around the tone. I build two Worksheet Charts using the same frequency grid F1:F101 and the two periodograms in Q and T. They are data on the same axis, not an interpolation between new frequencies.
Configuring the linear view (Figure 21)
I select F1:G5 as a starting point, open Chart (85) and press Add selection (86) to create a new tab without replacing the FFT one. In X column and Y columns (87) I set F and Q T; First row = 1, Last row = 101 (88). I keep Kind = line, Panels = overlay, Marker = circle and Legend = inside (89). The title is PSD at 205 Hz - rectangular Q and Hann T. To look at the central bins, I choose X minimum = 140, X maximum = 270, Y minimum = 0 and Y maximum = 0.03 (90), linear scales. I confirm with Apply (91) and wait for the rendering.


Let us look at the two central circles at 200 and 210 Hz: neither of them coincides with the actual frequency of 205 Hz. With the rectangular window, contributions are clearly visible at 180, 190, 220 and 230 Hz as well. With the Hann window the values of the central bins are higher and those of the distant bins lower in this particular case; this does not mean that the amplitude of the tone has grown. The lines serve to connect the discrete coefficients, not to indicate that I have calculated a continuous PSD at all frequencies. The linear detail is useful for reading the larger values but squashes the small ones near zero.
Configuring the semilogarithmic view (Figure 23)
So I prepare a second view without changing the data. I repeat Add selection and the configuration of columns F, Q, T, rows 1–101, line and circle. I choose the title PSD at 205 Hz - leakage on log scale; X minimum = 0 and X maximum = 1000 Hz (92), Y maximum = 0.1, Y minimum left automatic to include all positive values, X scale = linear, Y scale = log (93). I confirm with Apply (94).


Now I see the difference that the linear scale was hiding: just a few tens of hertz away from the tone, the red curve drops rapidly compared with the blue one. The vertical axis is logarithmic: vertical shifts represent ratios, not constant differences. The phenomenon is deterministic leakage of the finite signal, not measured electronic noise. In the comparison, the 15 Hz equivalent noise bandwidth just calculated for the Hann window must not be neglected.
These are native working views: the automatic labels F and T and the notation (unspecified)^2/Hz faithfully reproduce the still incomplete metadata of the columns. They are the initial working views; I will take them up again with declared physical units in section 5.7.
5.6. From the normalized sine wave to the PSD with physical units
To give physical meaning to the synthetic data, I separate the shape of the signal from its amplitude: P1:P200 contains the numerical samples of the normalized sine wave and W1 represents 1 mV. With Go to W1 (95) and Data / Lineage (96) I check the value and unit of the declared amplitude.

In X1 I use the formula =numeric.multiply(P1:P200,W1). In this version the vector product lost the unit, while the scalar check in Y1, =P2*W1, kept it. To reproduce this step in P012 I apply micropatch MP008: with the program closed, I follow the README contained in the ZIP, replace the file indicated and restart GX-TXT. The fix uses the unit registry for the vector product; it does not modify the CORE.
I reopen the session and choose X2 (97). Data / Lineage shows 0.000600420225 V (98), the same physical value as the scalar check Y1 apart from numerical rounding. The new column X expresses the samples in volts (99), without modifying P.

I recalculate the rectangular PSD directly from X. In the Functions tab I choose numeric.signal_periodogram (100), signal = X1:X200 (101), sample_rate = 2000, options = nfft=200 window=empty() (102–103). After Preview fields I choose psd_real; I set Z1 (104) and press Apply result (105) only once, waiting for completion.

With Go to Z21 (106) I read in Data / Lineage (107) the new value at the 200 Hz bin (108): 2.069664296 × 10−8 V²/Hz. It is consistent with Q21 = 0.020696643, interpreted in mV²/Hz, since 1 mV² equals 10−6 V². It is not an independent measurement of the power, but a consistency check of the periodogram with a dimensioned input.

One limitation remains: the periodogram emits the unit (V)^2/Hz, but the arithmetic does not accept this syntax. In AA1 (109) I try =Z21*1 and read the message (110). I do not remove the units and I do not rewrite the result by hand.

The check stops here until I make the unit syntax consistent; I keep the original columns Q and T and the results of the new periodogram in Z.
5.7. How much of the signal ends up outside the four central bins?
To repeat the experiment on P012 I apply, after MP008, micropatch MP009. With GX-TXT closed I extract the ZIP and replace the file indicated in the README, in the framework directory. The fix makes unit expressions with parentheses and integer powers compatible with the unit registry, keeping the prefixes and their conversion factors. It does not assign a physical meaning to unknown units. I reopen the Worksheet: in AA1 (111), Data / Lineage shows 2.0696642962557807 × 10−8 V²·s (112). It is the same quantity as Z21, since Hz = s−1. The formula now works without removing or replacing the metadata.

I repeat the periodogram with the Hann window, this time using X1:X200 (113), the signal expressed in volts. I keep sample_rate = 2000, set Options = nfft=200 window=S1:S200 (114), choose the psd_real field after Preview fields, destination AB1 (115) and Apply result (116). I wait for completion.

Without changing the signal, I select frequency_hz (117) as the result field and R1 (118) as the destination; I press Apply result. Columns R, Z and AB now contain respectively the frequencies in Hz and the rectangular and Hann PSDs in V²/Hz, at the same 101 frequencies. The step Δf is no longer just the number 10: I obtain it from R2−R1, with the unit Hz.

In Cell & Formula, with Go to (119) I reach AC1, enter (120) the following formula and press Apply (121). The vector function returns four results: the two total integrals, then the two integrals outside the common band of the 190, 200, 210 and 220 Hz bins, in the same order. Rows 1–19 and 24–101 correspond to the other bins. I do not use a trapezoidal integrator because the one-sided periodogram has already handled the DC and Nyquist bins appropriately.
=vector((R2-R1)*numeric.sum(Z1:Z101),(R2-R1)*numeric.sum(AB1:AB101),(R2-R1)*(numeric.sum(Z1:Z19)+numeric.sum(Z24:Z101)),(R2-R1)*(numeric.sum(AB1:AB19)+numeric.sum(AB24:AB101)))

In Data / Lineage (123) I check that the vector has the unit V² (124): multiplying the PSD by Δf has correctly removed the inverse hertz.

To read the out-of-band fraction as a percentage and the ratio between the two contributions, I go to AD1 (125) and write (126) the formula =vector(100*AC3/AC1,100*AC4/AC2,AC3/AC4). I press Apply (127) and read AD1:AD3 (128). The ratio is dimensionless.

| Quantity | Rectangular | Periodic Hann |
|---|---|---|
| Total integral (V²) | 5.000000 × 10−7 | 5.000000 × 10−7 |
| Total integral (mV²) | 0.500000 | 0.500000 |
| Out-of-band contribution (V²) | 4.9350454009 × 10−8 | 4.4911453467 × 10−10 |
| Out-of-band fraction (%) | 9.87009 | 0.089823 |
| ENBW (Hz) | 10 (theory) | 15 (verified) |
The result confirms the prediction of 0.5 mV² for both windows, in this particular experiment. The Hann window reduces the contribution outside the chosen band by a factor of 109.88: about two orders of magnitude. This is not a reduction of the electronic noise of the circuit, nor a universal factor: it applies to the 205 Hz sine wave, the 100 ms duration and the four-bin band defined here. The Hann window instead increases the equivalent noise bandwidth of the single bin by a factor of 1.5.
5.8. The two graphs with physical units
Configuring the linear view with physical units (Figure 36)
I go back to the two Worksheet views. In the Live native charts selector (129) I choose chart_2 and replace X column with R and Y columns with Z AB (130), keeping rows 1–101, circular markers, legend and linear scale. I set X = 140–270 Hz and Y = 0–3 × 10−8 V²/Hz (131); the maximum corresponds to 0.03 mV²/Hz. I confirm with Apply (132).


The difference between the two maxima of the rectangular window at 200 and 210 Hz comes from the fact that the record is finite and the signal is real; there are not two distinct sine waves. The circles are the spectral samples actually calculated, not a continuous curve. The graph makes it possible to distinguish the four bins of the reference band, but it is not enough to read the smaller contributions.
Configuring the semilogarithmic view with physical units (Figure 38)
For the full view I choose chart_3 (133), again assign R and Z AB (134), X from 0 to 1000 Hz, Y maximum 10−7 V²/Hz with automatic minimum (135). I keep Y scale = log (136) and press Apply (137).


The visual and the quantitative comparisons tell the same story: leakage far from the frequency of the tone decreases greatly, but the choice of window also changes the spectral response and the noise bandwidth. The mean square value must not be confused with the spectral density or with the dissipated power.
5.9. Publishing the comparison in Plots
Procedure in GX-TXT: publication and label (Figures 40–41)
With chart_3 selected, I use Publish immutable Graph to Plots (138). The confirmation message (139) identifies the Dataset and the native graph. The Dataset keeps the 101 frequencies and the two PSDs; there is no need to duplicate the Dataset for the linear detail already kept in the Worksheet.

In Plots I select the new variant p0002. I check the labels: the Y label may inherit the description of the previous FFT graph. With Presentation → Title and labels I set Y Left label (140) to PSD (V^2/Hz) and confirm with Save (141). I use Render → Rerender selected and check the result. I have changed only the presentation, not the values of the Dataset.


6. What will I need for the lock-in?
I started with a coherent sine wave to understand the FFT, normalization and Parseval. Then I moved the tone by only 5 Hz, showing that a discrete frequency grid can spread the contribution of a single sine wave over many bins. I verified the preservation of the mean square value in the case studied and the trade-off between leakage and ENBW. These results explain why it is not enough to look for a bar in the spectrum to measure a weak signal: you need to know how the measurement is built, which frequencies contribute and what noise bandwidth is actually collected.
The results at a glance
- Coherent 200 Hz sine wave, 200 samples at 2 kHz: raw FFT magnitude 100 at bin 20; normalized amplitude 1 mV; PSD 0.05 mV²/Hz; ASD 0.2236 mV/√Hz; Parseval 0.5 mV², with a time−frequency difference of −5.6 × 10−17 mV².
- 205 Hz sine wave, halfway between two bins: fraction outside the four-bin band 9.87% with the rectangular window and 0.0898% with the Hann, a reduction by a factor of 109.9; total integral 0.5 mV² for both.
- Equivalent noise bandwidth: 10 Hz for the rectangular window, 15 Hz for the periodic Hann (1.5 Δf).
The test with the coherent sine wave confirms the peak and the integral of the manual PSD and of the periodogram; it is not a check of the equality of every single bin. The results obtained here are numerical, on synthetic signals, and not bench measurements. The next step, in the article Correlation and autocorrelation, will be correlation: instead of looking only at the frequency distribution, I will compare the signal directly with a reference shape. It is the step that prepares the synchronous detection of the lock-in.