Discussion of article "Statistical Distributions in MQL5 - taking the best of R" - page 19

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
There is a wish to add Kolmogorov distribution to the library. It is very useful because of its use in the Kolmogorov-Smirnov criterion and in the problem of searching for the decomposition of a random process.
I will leave it here just in case. Calculation of CDF and its additions for distribution of Kolmogorov-Smirnov statistic for two-sided one-sample test.
CDF of hypergeometric distribution is incorrectly calculated by MathCumulativeDistributionHypergeometric() function. By definition, the probability distribution function must be defined for any real number. Below is a script on mql5 with its results and, for comparison, the same on R.
result:
-1.0 nan 2
0.0 0.0 0
0.5 nan 2
zero divide in 'Hypergeometric.mqh' (241,35)
Result:
[1] 0.0000000 0.0000000 0.0000000 0.2222222
You passed incorrect arguments and got ERR_ARGUMENTS_INVALID (2). We are checking the input parameters in more detail, and R appears to have replaced the answer with zeros.
Some (not all) binomial coefficients are negative, for example:
result: -309196571788882235
should be: 349615716557887488
Because of the large K (28) the 64-bit long overflowed there. The return value is long.
To count values within such limits, you need to rewrite the function to double values.
You passed incorrect arguments and got ERR_ARGUMENTS_INVALID (2). We check the input parameters in more detail, and R seems to have replaced the answer with zeros.
1) Any CDF - probability distribution function (discrete ones are no exception!) MUST DEFINITELY be defined for all real numbers. Below is an analogue of the code in R with its result, showing how this should count in reality. By the way, you have some discrete CDF functions counting correctly and some not.
2) For value 1 you get a division by zero error.
1) Any CDF - probability distribution function (discrete ones are no exception!) MUST DEFINITELY be defined for all real numbers. Below is an analogue of the code in R with its result showing how this should be considered in reality. By the way, some discrete CDF functions you have counted correctly and some you have not.
2) For value 1 you get a division by zero error.
Read the code of the function and its check, it is in the source code.
I don't have R at hand, I have to check it separately. I see division by zero, we need to understand the boundary conditions.
Because of a large K (28), the 64-bit long was overflowed there. The return value is long.
To count values within such limits, you should rewrite the function to double values.
It is clear. It's just that there is an error with the logarithm of the binomial coefficient at integer arguments and I thought that this was the reason. Now I've looked at the code and realised that I was wrong - the reason is something else.
result:
test_clog (EURUSD.m,MN1) -nan(ind)
test_clog (EURUSD.m,MN1) 40.39561099351077
PS Wrong, the problem is also in overflow
There is no R at hand,
R online
Some trouble with NoncentralBeta. I took the script from the Documentation.
These are the results for different parameters.
Formula in Documentation:
Is the analogue in Wikipedia:
Looked at the code.
The MathRandomNoncentralBeta() function has lines like this:
The same Wikipedia has this:
The noncentral beta distribution (Type I) is the distribution of the ratio
where
is anoncentral chi-squared random variable with degrees of freedom m and noncentrality parameter 𝜆 , and 𝜒 𝑛 2 is a centralchi-squared random variable with degrees of freedom n , independent of 𝜒 𝑚 2 ( 𝜆 ) .
That is, two random variables are taken, where the first is from a non-central chi-squared distribution and the second is from a central one. Probably the code can be corrected to this:
The modified graphs in the example will be below.