文章 "MQL5 中的统计分布 - 取最佳的 R" - 页 18

 
Alexey Nikolaev:

您好,
,在 R 中计算伽马分布的量值时遇到了一个问题
:
> qgamma(0.05,2,scale=1)
[1] 0.3553615
> qgamma(0.05,10,scale=1)
[1] 5.425406

,在 mql5 中:

结果:
0.3553615106986621
错误 4

build 1596

更改了伽玛分布的量化计算。修正了附录中的 Gamma.mqh 版本(在 MQL5\Include\Math\Stat\ 中替换)。

计算结果:

2017.11.06 21:03:56.580 TestExample (USDJPY,M5) 0.3553615106986623
2017.11.06 21:03:56.580 TestExample (USDJPY,M5) 5.425405697091294
附加的文件:
Gamma.mqh  32 kb
 
帮助页面 上写的是 MathProbabilityDensityGamma() 而不是 MathProbabilityDensityNoncentralBeta()
 
Aleksey Nikolayev:
帮助页面 上写的是 MathProbabilityDensityGamma() 而不是 MathProbabilityDensityNoncentralBeta()

谢谢,已更正

 

MathCumulativeDistributionHypergeometric() 函数错误地计算了超几何分布的 CDF。根据定义,概率分布 函数必须为任何实数定义。下面是 mql5 上的脚本及其结果,为了便于比较,还提供了 R 上的相同结果。

#include <Math\Stat\Hypergeometric.mqh>

input int nall=9;  // 所有
input int nsc=2;   // 全部成功
input int nsm=8;   // 样本数量

void OnStart()
  { int er;
    double k[]={-1,0,0.5,1};
    for(int i=0; i<4; ++i)
      Print((string)k[i]+" "+(string)MathCumulativeDistributionHypergeometric(k[i],nall,nsc,nsm,er)+" "+(string)er);
  }

结果

-1.0 nan 2

0.0 0.0 0

0.5 纳 2

在'Hypergeometric.mqh'(241,35)中除以零

nall <- 9 #  all
nsc <- 2  #  all success
nsm <- 8  #  sample size

k <- c(-1, 0, 0.5, 1)
phyper(k, nsc, nall-nsc, nsm)

结果:

[1] 0.0000000 0.0000000 0.0000000 0.2222222

 
Aleksey Nikolayev:

MathCumulativeDistributionHypergeometric() 错误地计算了超几何分布的 CDF。

感谢您的留言,我们将对此进行研究。

 
我们希望将Kolmogorov 分布 加入库中。该分布非常有用,因为它可用于柯尔莫哥洛夫-斯米尔诺夫准则和搜索随机过程的不和谐问题。
 

如果我没有弄错的话,MathQuickSort*() 快速排序功能不会填充 原始数组的索引数组:

#include <Math\Stat\Math.mqh>

void OnStart()
  { double a[]={1.5, 2.0, -1.0, 0.0};
    int na=ArraySize(a);
    int ix[]; ArrayResize(ix,na);
    for(int i=0; i<na; ++i) ix[i]=0;
    
    //MathQuickSort(a,ix,1,2,1);
    //MathQuickSort(a,ix,1,2,-1);
    MathQuickSortAscending(a,ix,1,2);
    /MathQuickSortDescending(a,ix,1,2);
    
    for(int i=0; i<na; ++i)
      Print((string)ix[i]+" "+(string)a[i]);
  }

结果

0 1.5

0 -1.0

0 2.0

0 0.0

 
Aleksey Nikolayev:

除非我弄混了,否则 MathQuickSort*() 快速排序功能不会填充 原始数组的索引数组:

在我们的实现中,索引数组本身并不填充,索引值必须在调用排序之前自己准备好:

    for(int i=0; i<na; ++i) ix[i]=i;

    for(int i=0; i<na; ++i) ix[i]=i+1;
或如果需要自然顺序。
 

Setslav

>>>隐藏产品是为了引起您的注意。

另外,我找不到在市场上发布新产品的按钮。是每个人都这样,还是只有我这样?如何发布 MT5 版本?

如果产品被版主隐藏,作者就无法返回。这符合逻辑

 

例如,有些(并非所有)二项式 系数是负数:

#include <Math\Stat\Math.mqh>

void OnStart()
  { Print(MathBinomialCoefficient(62,28));
  }

结果: -309196571788882235

应为:349615716557887488