Coefficient-of-Determination Fourier Transform

This algorithm is designed to perform numerical transforms to convert data from the temporal domain into the spectral domain. This algorithm obtains the spectral magnitude and phase by studying the Coefficient of Determination of a series of artificial sinusoidal functions with the temporal data, and normalizing the variance data into a high-resolution spectral representation of the time-domain data with a finite sampling rate. What is especially beneficial about this algorithm is that it can produce spectral data at any user-defined resolution, and this highly resolved spectral data can be transformed back to the temporal domain.


Introduction
The Fourier Transform [1][2][3][4][5][6][7] is one of the most widely used mathematical operators in all of engineering and science [8][9][10].The Fourier Transform can take a temporal function and convert it into a series of sinusoidal functions, offering significant clarity on the nature of the data.While the original Fourier Transform is an analytical mathematical operator, Discrete Fourier Transform (DFT) methods are overwhelmingly used to take incoherent temporal measurements and convert them into spectral plots based on real, experimental data.
The author proposes a numerical algorithm to perform a highly-resolved spectral transform of a temporal function of limited resolution.The spectral magnitude is determined by finding the magnitude of the Coefficient of Determination of the function as compared with a given sinusoidal function; this represents the independent spectral value as a function of the sinusoidal frequency.Rather than the spectral domain being proportional to the time step, the user defines exactly which frequencies are necessary to investigate.The spectral domain can be as large or as resolved as is necessary; the resolution possible is limited only by the abilities of the computer performing the transform.

Spectral Transform
The transform starts by first determining the peak total range of the data in the temporal domain; this range will become the base amplitude of the spectral series.The computer then generates a series of sine and cosine functions at each frequency within the spectral domain, and compares each of these sinusoidal functions to the temporal data to be transformed.In the comparison, a coefficient of determination is found and saved.To accommodate fluctuations in phase, each frequency generates both a sine and cosine function; this ultimately results in real and imaginary spectral components.Finally, the magnitudes of the coefficient of determination data are normalized, and the result is an accurate spectral representation of the temporal function.
The Fourier Transform is one of the most utilized mathematical transforms in science and engineering.By definition, a Fourier Transform will take a given function and represent it by a series of sinusoidal functions of varying frequencies and amplitudes.Analytically, the spectral function where i is the imaginary term (i = √ −1), f(t) is any temporal function of t to be transformed, and ω (rad/s) represents the frequency of each sinusoidal function.The inverse of this function is Conceptually, the spectral function F(ω) represents the amplitudes of a series of sinusoidal functions of discrete frequencies ω k (rad/s) Often in practical application, one does not have an exact analytical function, but a series of discrete data points at discrete times t n .If it is necessary to convert these discrete data into the spectral domain, the traditional approach has been to use the Discrete Fourier Transform (DFT) algorithm, often known as Fast Fourier Transform (FFT).The DFT algorithm is, by definition [11,12] where F(ω k ) is a discrete spectral data point, and f (t n ) is a discrete data point in the temporal domain.
With DFT, the spectral resolution is proportional to the temporal resolution, and it is often the case that the limited temporal data will not be sufficient to obtain the spectral resolution desired.
If one wants to obtain frequency information, there is a certain minimum temporal resolution necessary to properly distinguish the frequencies; this is known as the Nyquist rate [13][14][15][16][17].
As demonstrated in Table 1 and Figure 1, two different cosine functions with frequencies of 1 and 9 have exactly the same results when resolved at a temporal resolution δt = 0.1.There are many approaches to implementing Fourier transforms on data of limited resolution.One method is to introduce a scaled coordinate system and identifying the Fourier variables as the direction cosines of propagating light have been used to spectrally characterize diffracted waves in a method known as Angular Spectrum Fourier Transform (FFT-AS) [18][19][20][21].Another technique of numerical Fourier Transform is Direct Integration (FFT-DI) [22], using Simpson's rule to improve the calculations accuracy.Finally, one of the simplest approaches to taking the Fourier transform with a limited temporal resolution is to use Non-uniform Discrete Fourier Transforms (NDFT) [23][24][25][26][27][28][29][30][31]] where 0 < p n < 1 are relative sample points over the range, and ω k is the frequency of interest.

Spectral Transform Algorithm
This algorithm, which the author calls the Coefficient of determination Fourier Transform (CFT), is an approach to obtain greater spectral resolution; the full spectral domain, or any frequency range or resolution desired, is determined by the user.Greater resolution or a larger domain will inherently take longer to solve, depending on the computer resources available.One advantage of this approach is that the spectral domain can also have varying resolutions, for enhanced resolution at points of interest without dramatically increasing the computation cost of each spectral transform.
At each discrete point in the spectral domain, the algorithm generates two sinusoidal functions where Φ k (t) is to represent the real spectral components, Φk (t) is to represent the imaginary spectral components, ω k is the discrete frequency of interest, t is the independent variable of the data of interest, and A is the amplitude of the function defined and the total range within the temporal data.
% MatLab code of the CFT algorithm % FFO is the function in the temporal domain.Sfct is a discrete function % of frequencies, selected by the user, to define the spectral domain FFavg=mean(FF0); FFstd=max(FF0)-min(FF0); for ii=2:ct sinfct=sin(2*pi*t*(Sfct(ii))); % Real cosine function cosfct=cos(2*pi*t*(Sfct(ii))); % Imaginary sine function corrR=R2fct(cosfct,FF0); % R^2 of real component corrI=R2fct(sinfct,FF0); % R^2 of imaginary component SpecFct(ii)=corrR+(i*corrI); % Saving the Spectral Function end SpecFct=FFstd*SpecFct/(sum(abs(SpecFct))); % Normalize the spectral function SpecFct(1)=FFavg; % Set the average of the temporal function (Sfct(1)=0) The next step is to take each of these functions, and find the Coefficient of Determination between the function and the temporal data, all with the same temporal domain and resolution [9,[32][33][34][35].The coefficient of determination is a numerical representation of how much variance can be expected between two functions.To find the coefficient of determination between two equal-length discrete functions G(t n ) and H(t n ), three coefficients are first calculated where N is the discrete length of the two functions, and Ḡ and H represent the arithmetic mean value of functions G(t n ) and H(t n ).The correlation coefficient, represented as R, is then determined as and the closer the two functions match, the closer the value of the correlation coefficient reaches R = 1.If there is no match at all, the correlation coefficient will be R = 0, and if the two functions are perfectly opposite of each other (G(t n ) = −H(t n )), the correlation coefficient goes down to R = −1.In practice, the coefficient of determination is often represented as the R 2 value This process is repeated for every sine and cosine function generated with each frequency within the spectral domain.The coefficients of determinations can be used to represent the spectral values, both real (cosine function) and imaginary (sine functions), for the given discrete frequency point.These functions of R 2 values for the real and imaginary components are then normalized to the maximum real and imaginary values, and multiplied by the amplitude A determined in Equation (8).The final outcome is a phase-resolved spectral transformation of the input function, but with a spectral domain as large or resolved as desired.end Finally, this spectral transformation can easily be converted back to the temporal domain.By definition, the temporal domain is merely the sum of the series of sinusoidal waves (Equation ( 3)), and thus the inverse CFT transform can simply be defined as

Initial Demonstration of the Spectral Transform Algorithm
To demonstrate the capability of this algorithm, six functions are generated based on the two similar functions demonstrated in Table 1 and Figure 1; the two functions are used with a temporal range of 0 to 1, with the same temporal resolution of δt = 0.1, and frequencies of both f = 1 and f = 9.The cosine functions are modified to have a phase shift of ±2π/3.The supplementary file Run_Initial_Study.zip contains the MATLAB code to run this analysis and replicate these results.
The spectral transform was taken of all six of these functions with both the CFT algorithm, as well as the NDFT algorithm defined in Equation ( 6).The spectral magnitude and phase from both methods are plotted in Figure 2. By using Equation (12) to get back to the temporal domain (one example is plotted in Figure 3), all six functions matched (R 2 > 0.996) with the spectral magnitude and phase from the CFT; there is no coherent match for the NDFT.This is realized by finding the coefficient of determination between the recovered temporal data and the original temporal data; the R 2 results are tabulated in Table 2.While the NDFT may give a clear picture of the spectral domain of the function, it is impossible to recover the function back to the original temporal domain without excessively computationally intensive matrix analysis.The strength of CFT transform lies in its inverse operator defined in Equation (12), with which the true temporal function can be obtained back from the spectral domain obtained with highly resolved CFT.12)) from the spectral plot obtained with both CFT and NDFT (Figure 2).One important point is that, while the CFT transform is a spectral representation of the transformed temporal function, the spectral function of this method is not a true Fourier transform defined analytically in Equation (1).Both functions are similar (see Figure 2), but not exact; this function, by definition, is the magnitude of the coefficient of determination R 2 of the temporal function with the associated sine and cosine wave.For this reason, the CFT versions of the spectral representation, while similar, are not identical to the NDFT versions, and thus are not true Fourier transforms.The power of these CFT spectral plots lie in the fact that they can be easily transformed back to the temporal domain.12) and the CFT spectral results, obtained with a limited initial temporal resolution of δt = 0.1.

Performance of the Spectral Transform Algorithm
In the previous sections, this algorithm was demonstrated to be an effective tool to determine spectral magnitude and phase.Next, this algorithm's performance was compared to both traditional FFT [11,12] of limited resolution, as well as the higher resolution NDFT method [23][24][25][26][27][28][29][30][31].Often in practical applications it is necessary to determine the frequencies of the peak spectral magnitudes with temporal data of limited resolution.In this example, a temporal function is comprised of four sinusoidal functions with an amplitude of 1.25, 1.5, 1.75, and 2, at frequencies of 20.80 Hz, 38.38 Hz, 61.38 Hz, and 77.55 Hz, at a phase shift of 0 • , 120 • , 240 • , and 0 • , respectively.Mathematically, the function can be described as The function is performed over a temporal duration of 1 unit of time.The function is plotted in Figure 4a, where the green lines represent the highly resolved function, and the blue circles represent the limited temporal data of 100 Hz one might practically receive if collecting experimental data.
A traditional FFT of this limited-resolution temporal data was collected, along with a CFT with a spectral domain of 0.01 Hz ranging from 0.01 Hz to 100 Hz, as well as a NDFT transform with the same refined spectral domain; the spectral magnitudes are all plotted in Figure 4b.The peak spectral magnitudes were numerically found in the spectral range of 10-30 Hz, 30-50 Hz, 50-70 Hz, and 70-90 Hz, and tabulated in Table 3.For all four frequencies, the CFT improved upon traditional FFT in terms of accurately centering on the frequency with peak spectral magnitude.In addition, with limited resolution tradition FFT cannot even characterize frequencies higher than half the resolution (Equation ( 5)); the spectral plots are limited up to 50 Hz.The NDFT method with the higher resolution allowed for spectral characterization above 50 Hz, and improved upon the accuracy of the spectral peaks when compared to the traditional FFT, but still with greater error than the CFT.In addition, the CFT results can be accurately transformed back to the temporal domain with Equation ( 12), and in this case the transform of the spectral results matched remarkably (R 2 = 0.99999) with the original temporal function, as demonstrated in Figure 4c.

Parametric Study of the Spectral Transform Algorithm
A parametric study of this transform was conducted to demonstrate that it can be used for high resolution measurements of the spectral frequency with a limited temporal resolution.To demonstrate this, 15 random frequencies were selected, ranging from 2 to 17 cycles over the duration of the measured window.Both the independent and dependent temporal variables are arbitrary values to demonstrate the transform function; the independent scale ranges from 0 to 1 and has 180 data points.The arbitrary dependent data had random averages between −1000 and 1000, with an amplitude of 200 and random noise to represent the typical randomness found in typical test data.Each of these 15 random frequencies was phase shifted by three random phases.All forty-five arbitrary functions were transformed into the spectral domain with this transform, with a frequency domain ranging from 0 to 20 cycles per unit time duration, and a frequency resolution of 1 mHz; two examples of these spectral results are presented in Figure 5.As a further test of the robustness of the transform, the spectral data were then converted back to the temporal domain, and the new temporal function was compared to the original function with the coefficient of determination method to ascertain errors from the transform.This spectral transform was remarkably effective at finding the peak primary frequency, often with accuracies down to tens of mHz.The functions of the peak frequencies (Figure 6), both of which were used for the initial function and the peak of the spectral transform, match with an R 2 value of 0.999991-effectively identical.The functions of the random phase angle at the peak frequencies (Figure 7), both of which were used for the initial function and the phase of the spectral transform at the peak frequency, match with an R 2 value of 0.9982, demonstrating that this transform can be used to capture both spectral magnitude and phase with great accuracy.Finally, the inverse of this spectral transform was conducted for each spectral output, and the errors between the original functions and the transformed-inverse-transformed function are minimal.As expected, not all of the fine random noise is captured; this would require a near infinite spectral domain, which would further increase computational costs, but the overarching shapes, magnitudes, and phases of the functions are consistently captured.Taking the coefficient of determination of each function pair, the value of R 2 is never less than 0.92.Two examples of the original function (lines) and the transformed-inverse-transformed function (stars) are represented in Figure 8.The tabulated results of all fifteen studies, for each of the three phase magnitude shifts, are demonstrated in Tables 4-6.

Conclusions
This effort has demonstrated a practical, working, invertible method of numerically transforming a 1D temporal function, called Coefficient of determination Fourier Transform(CFT), obtaining high-resolution in the spectral domain from limited resolution in the temporal domain, and retaining the ability to go back to the temporal domain from the spectral data with Equation (12).The CFT algorithm, while very similar, is not a true Fourier transform as defined analytically in Equation (1); it is a representation of the spectral magnitudes as related to its coefficient of determination R 2 value.The CFT transform inherently is more computationally expensive than traditional DFT and NDFT methods.Any desired spectral resolution and spectral domain can be used to characterize the input data.The transform can even convert the function to a spectral domain of varying resolution, so that peaks can be accurately identified without too much computational expense.The algorithm was first tested with simple phase-shifted cosine functions, and the inverse transform of the spectral resolution matched remarkably.Next, the spectral transform algorithm was tested at fifteen different random frequencies, all with three different random phases, all with random noises and errors, and consistently the transform was able to characterize the peak frequency and phase angle remarkably, with a higher degree of accuracy than one can expect with traditional DFT methods.

Figure 2 .
Figure 2. Spectral results of the function cos(2π•x) with a δs = 0.1, with both the proposed CFT in magnitude (a) and phase (b), as well as NDFT in magnitude (c) and phase (d).

Figure 3 .
Figure 3. Demonstration of the function cos(2π•t), both the original function (solid green lines), and the output (blue circles) obtained from Equation (12) and the CFT spectral results, obtained with a limited initial temporal resolution of δt = 0.1.

Figure 4 .
Figure 4. Performance data for an input temporal plot of 101 data points of resolution: (a) a comparison of the data to the true, high resolution function; (b) the spectral function, both the CFT and a tradition FFT analysis; and (c) the original versus the inverse transform of the spectral function.

Table 2 .
Coefficient of determination between the original temporal function and the temporal function retrieved (Equation (

Table 3 .
Performance results of peak frequency, comparing CFT versus FFT, with a temporal resolution of 101.

Table 4 .
Comparison of results, for phase shift angle 1.

Table 5 .
Comparison of results, for phase shift angle 2.

Table 6 .
Comparison of results, for phase shift angle 3.