Machine learning in trading: theory, models, practice and algo-trading - page 199
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Comment then, in order of literalism, how for a uniform continuous distribution the density at the extreme point is positive and the integral is zero: https://en.wikipedia.org/wiki/Uniform_distribution_(continuous)
Let's go back to the original statement about R errors in the article.
Our opinion stands - errors are present and caused by carelessness in implementation.
The point is that @Quantum is a pure implementation and full check of R's analog of math libraries in MQL5.
This is not the reasoning of a theorist. And he digs deep when writing unit tests, which provide confidence in the correctness of the library.
Do not assume a priori that everything is correct in R. On the contrary, I would say that even if there is a C++ implementation of functions there, everything is quite primitive. And in terms of speed, you can see that the MQL5 library in the source code on our compiler wins by 3 times on average.
We took the trouble to double-check everything and found obvious errors. These errors have been confirmed:
Look at the dates of publications, please. You will see how the work is going with the advice of scientists.
In addition, it would be a mistake not to consider @Quantum a scientist.
Dear Renat!
According to your last posts I have the following questions, which are fundamental for me:
1. Judging by the date of publication of your article it is the year 2003. Naturally, R, as well as any other software system, has bugs and always publishes a list of fixes when it publishes a release. At the same time, R has always emphasized that the advantage of R is the low level of bugs at the expense of an extremely large number of users. And here since 2003 a bug in the algorithm has been detected at the publication level and not fixed. This is not clear to me.
Have you made a request to R on this issue?
I'd like to see the code by which the performance of R and MQL5 was compared.
I appreciate it in advance.
Dear Renat!
I have the following questions about your last posts, which are fundamental for me:
1. Judging by the date of publication of the article - it is the year 2003. Naturally, R, as well as any other software system, has bugs and always publishes a list of fixes when it publishes a release. At the same time, R has always emphasized that the virtue of R is the low level of bugs at the expense of an extremely large number of users. And here since 2003 a bug in the algorithm has been detected at the publication level and not fixed. This is not clear to me.
It is elementary and absolutely clear.
Everyone makes mistakes, that's what developers are all about. We make a ton of mistakes and do not get discouraged.
This error in R is just from carelessness and reliance on one basic function that screwed up the others. Correct it.
Have you made a request to R on this issue?
We have conducted tests, we have looked into everything in details while writing the library, we have constantly compared the results of MQL5 - Wolfram Alpha - R and we have shown our results and are ready to publicly answer for them. Of course, we have attached three large scripts with unit tests and a benchmark to our math package (which is in the source code).
I'm sure @Quantum will write a bug report in R. The updated article was released just a couple of hours ago.
I'd like to see the code comparing the performance of R and MQL5.
The MQL5 benchmark code is located in \Scripts\UnitTests\Stat\TestStatBenchmark.mq5, and the R code is available at the end of the article Statistical Distributions in MQL5 - take the best from R and make it faster, see "Appendix. Results of calculating time for statistical functions".
Be sure to upgrade to MetaTrader 5 build 1467 by connecting to the MetaQuotes-Demo server, please. It is in this beta version that we have included the new library and all testing scripts.
This is elementary and perfectly understandable.
Everyone makes mistakes - that's the nature of developers. We make a ton of mistakes and don't get discouraged.
This error in R is just from carelessness and trust in one basic function that screwed up others. Correct it.
We have conducted tests, we have looked into everything in details while writing the library, we have constantly compared the results of MQL5 - Wolfram Alpha - R and we have shown our results and are ready to publicly answer for them. Of course, we have attached three large scripts with unit tests and a benchmark to our math package (which is in the source code).
I'm sure @Quantum will write a bug report in R. The updated article was released just a couple of hours ago.
The benchmark code in MQL5 can be found in \Scripts\UnitTests\Stat\TestStatBenchmark.mq5, and the code in R can be found at the end of the article Statistical Distributions in MQL5 - take the best from R and make it faster in "Appendix. Results of Calculating Time for Statistical Functions".
Be sure to upgrade to MetaTrader 5 build 1467 by connecting to the MetaQuotes-Demo server, please. It is in this beta version that we have included the new library and all testing scripts.
I cannot form my own opinion on the comparison of speeds so far. And it is a matter of principle.
The thing is that R is an ideal environment for development - an interpreter in one word. But the code that exists during development is very different from the working code - the number of lines many times. And the working code, it is very short and at the same time very capacious meaningfully. That's why you should compare on any functions from packages, which make sense when making trading decisions, for example, randomforest, which use computationally capacious algorithms, matrix operations, loading of all cores....
PS.
You are using an outdated version of R. You should take R version 3.3.1 (2016-06-21) from MRAN - Microsofn R Open website. It is obligatory to install MKL. Microsoft claimed in the mentioned R release that it was able to increase execution speed of some packages and functions up to 50 (!) times.
So far I can't form my own opinion about the performance comparison. And this is a matter of principle.
The fact that R is the ideal environment for development - an interpreter in a word. But the code that exists during development is very different from the working code - the number of lines many times. And the working code, it is very short and at the same time very capacious meaningfully. Therefore we should compare it on any functions from packages, which make sense when making trading decisions, for example, randomforest, which uses computationally capacious algorithms, matrix operations, loading of all cores....
We methodically translate R features into MQL5. And in such a way that the essence of function calls turns out to be very similar.
Here is an example of the correspondence from the article:
Uniform
We try to make the code from R be almost identical in size and time to write it in MQL5.
The first step is to put in beta the graphical library and demonstrate the same size code in R and MQL5 together with images.
I doubt that the regular version of R can unexpectedly speed up - the code there does not change much. It is clear that some functions can be sped up, especially matrix ones. And your statement confirms my opinion that the code in R is written rather sloppily in terms of performance.
If you read the article, you'd see that we got speedups up to 46 times even on basic functions without any multithreading and MKL:
The calculations were done on an Intel Core i7-4790, 3.6 Ghz CPU, 16 GB RAM, Windows 10 x64. Measurement results of calculation time in microseconds
PDF calculation time (µs)
PDF calculation time (µs)
R/MQL5
CDF calculation time (µs)
CDF calculation time (µs)
R/MQL5
quantile time (µs)
quantile computation time (µs)
R/MQL5
random numbers generation time (μs)
random numbers generation time (μs)
R/MQL5
But we will check the specified version of course. Both for speed and performance.
You are wrong about the "wrong answer"
...
For example, the MQL documentation gives an example on the arcsine and states that arcsine(2) = infinity. That's not accurate. Exactly: arxinus(2) = NaN, i.e. no numerical value, arxinus(1) = Inf, but skipping quotes during trading = NA, i.e. should be (or could be on weekends) and they are not.
I wrote this with a bit of irony about the wrong answers. I should have added a smiley face... I actually added at the end that it's not a bug in both cases, as the behavior of compilers and interpreters in non-defenied function areas is entirely dependent on system architecture and developers. Better to return nan in that case, of course.
I mean, don't call a function with parameters for which it is not defined and then compare results with another library, you could find hundreds of "mistakes" that way.
By the way, it is interesting example with the arcsinus.
The mql is
MathArcsin(1) = MathArcsin(2) = -nan(ind)
Wolfram -
Arcsin(1) = Pi/2
Arcsin(2) = something complex. There is no solution with a valid result.
R -
asin(1) = Pi/2
asin(2) = nan (the answer for real numbers)
asin(2+0i) = something complex, like in wolfram
wiki says that asin(1) is still defined(https://en.wikipedia.org/wiki/Inverse_trigonometric_functions), you can write a bug report to servicedesk.
But asin(2) is already undefinable, everything is normal and matches everywhere.
And again about last post - to divide by 0 in simple math is impossible, so it's logical that mql script crashes with error, there are no bugs here. But it's very strange to see such meticulousness to the accuracy of results up to 16 decimal places, and return nan or Inf when dividing by zero is impossible for some reason. Imho need to return Inf and not torment developers with sudden crashes of their scripts.
To disable real division control, use the parameter FpNoZeroCheckOnDivision=1 in the [Experts] section of the metaeditor.ini file
If this parameter is present, the following code will produce inf
Of course, the presence of this parameter will not save you from a compilation error when dividing by a constant 0.0
'0.0' - division by zero in the constant expression s1.mq5 8 12
Renat, was this transfer of some functions from R to mql really the surprise you were talking about?
No.
Surprise doesn't make sense, we will do everything within MQL5 and MetaTrader 5.
If this parameter is present, the following code will produce inf