Coefficient-of-determination Discrete Fourier Transform

This algorithm is designed to perform Discrete Fourier Transforms (DFT) to convert temporal data into spectral data. This algorithm obtains the Fourier Transforms 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 DFT algorithm is that it can produce spectral data at any user-defined resolution.


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 Fourier 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.

Fourier 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 correlation coefficient 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 correlation factor data is 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 Fourier Transform is represented as [1,2] 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 frequency ω (rad/s) Often in practical application, one does not have an exact analytical function, but a series of discrete data points.If it is necessary to convert this discrete data into the spectral domain, the traditional approach has been to use the 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 x 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.

Algorithm
This algorithm, which the author calls the Coefficient of Determination Fourier Transform (CDFT), 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 Fourier Transform.
At each discrete point in the spectral domain, the algorithm generates two sinusoidal functions where F n (t) is to represent the real spectral components, Fn (t) is to represent the imaginary spectral components, ω n 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.
The next step is to take each of these functions, and find the Coefficient of Determination (CoD) between the function and the temporal data, all with the same temporal domain and resolution [9,[32][33][34][35].The CoD is a numerical representation of how much variance can be expected between two functions.To find the CoD between two equal-length discrete functions F n (t) and f n (t), three coefficients are first calculated where N is the discrete length of the two functions, and Fn and fn represent the arithmatic mean value of functions F n and f n .The CoD, represented as R, is then determined as and the closer the two functions match, the closer the value of the CoD reaches 1.If there is no match at all, the CoD will be equal to 0, and if the two functions are perfectly opposite of each other ( the CoD goes up to -1.In practice, the CoD is often represented as the R 2 value, This process is repeated for every sine and cosine function generated with each frequency within the 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, and thus the inverse Fourier transform can simply be defined as

Initial Demonstration of 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 Fourier transform was taken of all six of these functions with both the CDFT 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 11 to get back to the temporal domain, all six functions matched with the spectral magnitude and phase from the CDFT; 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 CDFT transform lies in its inverse operator defined in equation 11, with which the true temporal function can be obtained back from the spectral domain obtained with highly resolved CDFT.This Fourier transform was remarkably effective at finding the peak primary frequency, often with accuracy's down to tens of mHz.The functions of the peak frequencies (Figure 5), both which were used for the initial function and the peak of the Fourier transform, matches with an R 2 value of 0.999991; effectively identical.The functions of the random phase angle at the peak frequencies (Figure 6), both which were used for the initial function and the phase of the Fourier transform at the peak frequency, matches 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 Fourier 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 squared 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 7.The tabulated results of all fifteen studies, for each of the three phase magnitude shifts, are demonstrated in Tables 3 -5.

Conclusion
This effort has demonstrated a practical, working, invertible method of numerically conducting a Fourier Transform, 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 11.While the CDFT 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 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 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 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.

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

Figure 4 .
Figure 4. Spectral results of the randomly generated functions, for frequencies of (a) 2.0256 (Hz/Rev) and (b) 13.0467 (Hz/Rev), but for different phases, magnitudes, and random noises.

Table 2 .
Correlation between the original temporal function and the temporal function retrieved (equation 11) from the spectral plot obtain with both CDFT and NDFT (Figures 2).
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 Preprints (www.preprints.org)| NOT PEER-REVIEWED | Posted: 1 August 2018 doi:10.20944/preprints201808.0009.v1Peer-reviewed version available at Computation 2018, 6, 61; doi:10.3390/computation6040061

Table 3 .
Comparison of Results, for Phase Shift Angle 1.

Table 4 .
Comparison of Results, for Phase Shift Angle 2. frequency and phase angle remarkably, with a higher degree of accuracy than one can expect with traditional DFT methods. peak