Interpolation, approximation and the like (alglib package) - page 8

 
All these conversions are not suitable for my task, the libraries are useless (studied). Let's go another way. But since no one understands anything about the essence of the question, I won't tell you which one.
 
Maxim Dmitrievsky:
All these transformations are not suitable for my task, the libraries are useless (studied). Let's go the other way. But since no one understands the essence of the question, I won't tell you which one.

Thank you, Maxim, for this thread. I am personally interested in you. I will follow your creative process.

I was always dragged into the abyss of AI.
The abyss draws me in.

 
Yes, it was very interesting to read. thanks a lot @Nikolai Semko
 
Maxim Dmitrievsky :
All these transformations for my task do not fit, they are useless (learned). Let's go another way. But since no one understands anything, I will not say how.

I understand the merits to some extent and definitely want to help and solve the problem since I understood the overall theoretical part of the problem to some extent, but when it comes to practical implementation in MQL5 code, then without the exact understanding of the code where you are stuck it is becoming difficult for me understand correctly to give some idea as to how to solve the problem or where is the problem exactly. I mean to what extent you have implemented in MQL5 and what are you looking for exactly in terms of MQL5 code or formula or function etc.

If you can transform your thoughts or the problem in the form of few lines of MQL5 code where you are stuck, then I will try my best to give some idea at least to solve it.

 
Nikolai Semko:

Sorry, I couldn't understand what you meant. Apparently due to my limitations. But I tried.
But take a look and use this example:
https://www.mql5.com/ru/forum/216298/page5#comment_6484839


The idea that any periodic function can be represented as a series of harmonically related sines and cosines was proposed by Baron Jean Baptiste Joseph Fourier (1768-1830).


Definition of a Fourier series

A functionf(x)is said tohave periodP iff(x+P)=f(x)for all values ofx.Let the period of the functionf(x) be. In this case,it is sufficient to consider the behaviour of the function in the interval[-π].
  1. Suppose that the functionf(x) with period is perfectly integrable in the interval[-π]. In this case the so-calledDirichlet integral is finite:π∫-π|f(x)|dx< ∞;

  2. Suppose also that the functionf(x) is single-valued, piecewise continuous (i.e. has a finite number of discontinuities) and piecewise monotone (has a finite number of maxima and minima).

If conditions 1 and 2are satisfied, thenthe Fourier seriesfor the functionf(x)exists and converges to the given function

Can a non-periodic function be expanded into a Fourier series? Yes - to do this, we assume that the interval on which we want to obtain the expansion is the period and scale it to[-π]
. But then when extrapolating beyond the decomposition interval (over the right edge), you should get the values of periodic function in the limit, which are the values of the left edge with a corresponding shift - period P.
Drawing is lazy - it's in the numerical methods course at universities, approximately on the second or third year of study. More precisely, it used to be studied (in my time) - I have no idea how it is now.
 
Vladyslav Goshkov:

The idea that any periodic function can be represented as a series of harmonically related sines and cosines was proposed by Baron Jean Baptiste Joseph Fourier (1768-1830).

Definition of a Fourier series

A functionf(x)is saidto have periodP iff(x+P)=f(x)for all values ofx.Let the period of the functionf(x) be. In this case,it is sufficient to consider the behaviour of the function in the interval[-π].
  1. Suppose that the functionf(x) with period is perfectly integrable in the interval[-π]. In this case the so-calledDirichlet integral is finite:π∫-π|f(x)|dx< ∞;

  2. Suppose also that the functionf(x) is single-valued, piecewise continuous (i.e. has a finite number of discontinuities) and piecewise monotone (has a finite number of maxima and minima).

If conditions 1 and 2are satisfied, thenthe Fourier seriesfor the functionf(x)exists and converges to the given function

Can a non-periodic function be expanded into a Fourier series? Yes - to do this, we assume that the interval on which we want to obtain the expansion is the period and scale it to[-π]
. But then when extrapolating beyond the decomposition interval (over the right edge), you should get the values of periodic function in the limit, which are the values of the left edge with a corresponding shift - period P.
Drawing is lazy - it's in the numerical methods course at universities, approximately on the second or third year of study. More precisely, they used to (in my time) study it - how now I have no idea.

It seems that you do not understand the sense of decomposition of the function into harmonics.
What left-hand edge is carried over the right-hand edge? What do you mean?

You understand that the point of a Fourier decomposition is to get a set of harmonics (sinusoids) of different frequency, amplitude and phase shift, so that when you add them up you get something similar to the original function from the data set.

Each sinusoid is like an infinite function and has neither a left edge nor a right edge. To extrapolate it, you just have to continue it, not join the "left" edge to the "right" edge.

And the periodicity of this harmonic sum will not be equal to the sampling range of the original approximated data, but will be equal to the distance between the moments when all harmonics of different frequency phase shifts simultaneously return to their starting values, and not the fact that this can happen, because it can happen only if all harmonics frequencies are multiples of the same value.

The blue line is the approximation, the red line is the extrapolation.

Files:
 
Nikolai Semko:

You seem to have a misunderstanding of the meaning of the function decomposition into harmonics.
Which left edge carries over to the right edge? What are you talking about?

You understand that the point of Fourier decomposition is to get a set of harmonics (sinusoids) of different frequency, amplitude and phase shift, so that when you add them up you get something similar to the original function from the data set.

Each sinusoid is like an infinite function and has neither a left edge nor a right edge. To extrapolate it, you just have to continue it, not join the "left" edge to the "right" edge.

And the periodicity of this harmonic sum will not be equal to the sampling range of the original approximated data, but will be equal to the distance between the moments when all harmonics of different frequency phase shifts simultaneously return to their starting values, and not the fact that this can happen, because it can happen only if all harmonics frequencies are multiples of the same value.

The blue line is the approximation, the red line is the extrapolation.

This very "distance between moments when all phase shifts..." in the Fourier series is exactly equal to a period, since arguments of trigonometric functions in it are x, 2x, 3x,...nx, and their periods are 1, 2, 3...n times common, respectively. Because of this such set of trigonometric functions has the property of orthogonality which results in independence of coefficients of Fourier expansion from each other and from the number of frequencies used for expansion. Having calculated expansion coefficients for n=1 (a1 and b1) we already know that these values will not change if we find ai and bi in the expansion with 5 frequencies. That's the beauty of it.

Why, is that not what you are doing? Do the values of the first decomposition coefficients change when you change the number of harmonics considered?

 
Vladyslav Goshkov:

...

There is a special Fourier extrapolation technique. A decomposition into harmonics is done, the amplitudes are extrapolated, and then the harmonics are collected with this changing amplitude. I don't remember exactly, but it goes something like this. There is an example of this method here in the code base.

 
Maxim Dmitrievsky:

Everyone has figured it out, they just don't know how to do

a random transformation of features for a neural network, as an output function, so that new data can be substituted

Very interesting)) "transformation of traits for a neural network". Where does a neural network have features? A neural network has inputs and outputs. By a deductive method one would conclude that it is the input of these signs to the neural network. But!!! "...as an output function"...

It's a fiasco, Marivanna, a fiasco!

 
Vladimir:

This very "distance between moments when all phase shifts..." in the Fourier series is exactly equal to the period, since the arguments of trigonometric functions in it are x, 2x, 3x,...nx, and their periods fit into a common 1, 2, 3...n times, respectively. Because of this such set of trigonometric functions has the property of orthogonality which results in independence of coefficients of Fourier expansion from each other and from the number of frequencies used in expansion. Having calculated expansion coefficients for n=1 (a1 and b1) we already know that these values will not change if we find ai and bi in the expansion with 5 frequencies. This is the beauty of it.

Why, is it different for you? Do the values of the first decomposition coefficients change when you change the number of harmonics taken into account?

No, this algorithm for finding harmonics does not use the fast Fourier transform butuses the Queen-Fernandez frequency calculation algorithm. (source code) By the way, aren't you the author? The name is the same, but the profiles are different.

The frequencies are calculated sequentially and are not multiples of each other. This can be seen both from the animated gif and from the code I presented above and now.
Here is an example of harmonic frequency coefficients from this example (just printed w):

2018.08.24 00:22:11.921 !Fourier (EURUSD,M1)    Гармоника 1 = 0.00492908
2018.08.24 00:22:11.921 !Fourier (EURUSD,M1)    Гармоника 2 = 0.01176861
2018.08.24 00:22:11.921 !Fourier (EURUSD,M1)    Гармоника 3 = 0.02124126
2018.08.24 00:22:11.921 !Fourier (EURUSD,M1)    Гармоника 4 = 0.02651676
2018.08.24 00:22:11.921 !Fourier (EURUSD,M1)    Гармоника 5 = 0.03511149
2018.08.24 00:22:11.922 !Fourier (EURUSD,M1)    Гармоника 6 = 0.01191667
2018.08.24 00:22:11.922 !Fourier (EURUSD,M1)    Гармоника 7 = 0.00586503
2018.08.24 00:22:11.922 !Fourier (EURUSD,M1)    Гармоника 8 = 0.04684633
2018.08.24 00:22:11.923 !Fourier (EURUSD,M1)    Гармоника 9 = 0.07585431
2018.08.24 00:22:11.923 !Fourier (EURUSD,M1)    Гармоника 10 = 0.05593456
Files:
6Fourier.mq5  16 kb
Reason: