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

 

Thank you,

just in case (in case it matters):

I have MT5 running via wine in ubuntu 14

 
I have MT5 running via wine in ubuntu 14
and yes, the system is 32-bit
 

Either I've messed something up, or there's a problem with the empirical density calculation. It looks as if the axes were mixed up during scaling:

#include <Math\Stat\Normal.mqh>
#include <Graphics\Graphic.mqh>
#define  NR 1000
#define  N 100
void OnStart()
  { double x[N], y[N], r[NR];
   if (!MathSequenceByCount(-1,1,N,x)) {Print("MathSequenceByCount() error "); return;}
   if (!MathProbabilityDensityNormal(x,0,1,y)) {Print("MathProbabilityDensityNormal() error "); return;}
   ChartSetInteger(0,CHART_SHOW,false);
   CGraphic graphic;
   graphic.Create(0,"G",0,0,0,750,350);
   graphic.CurveAdd(x,y,CURVE_LINES,"theor.");
   if (!MathRandomNormal(0,1,NR,r)) {Print("MathRandomNormal() error "); return;}
   if (!MathProbabilityDensityEmpirical(r,N,x,y)) {Print("MathProbabilityDensityEmpirical() error "); return;} 
   graphic.CurveAdd(x,y,CURVE_LINES,"empir.");
   graphic.CurvePlotAll();
   graphic.Update(); 
   Sleep(30000);
   ChartSetInteger(0,CHART_SHOW,true);
   graphic.Destroy(); 
  }

far away

 

Error in calculating RMS

//+------------------------------------------------------------------+
//| Computes the variance of the values in array[] |
//+------------------------------------------------------------------+
double MathVariance(const double &array[])
  {
   int size=ArraySize(array);
//--- check data range
   if(size<2)
      return(QNaN); // need at least 2 observations
//--- calculate mean
   double mean=0.0;
   for(int i=0; i<size; i++)
      mean+=array[i];
   mean=mean/size;
//--- calculate variance
   double variance=0;
   for(int i=0; i<size; i++)
      variance+=MathPow(array[i]-mean,2);
   variance=variance/(size-1);
//--- return variance
   return(variance);
  }
 
fxsaber:

Error when calculating RMS

Is this an answer to someone or just talking to yourself? Tomorrow I will look at the source code, maybe there is an error there.

 
Rashid Umarov:

Is this an answer to someone or just talking to yourself? Tomorrow I will look at the source code, maybe there is a mistake there.

The article describes functions from Math.mqh, in particular. I have extracted the source code of one such function and highlighted the error.

 
fxsaber:

The article describes functions from Math.mqh, in particular. I have extracted the source code of one such function and highlighted the error.

is the calculation of unbiased, i.e. standard deviation. That is, there are two quadratic ones :-) if divided simply by size - then the mean-square, if by size-1 then unbiased or standard. In different cases different ones are used, but in case of large size the difference is vanishingly small
 
Maxim Kuznetsov:
is the calculation of unbiased, or standard deviation. In other words, there are two quadratic ones :-) if divided simply by size - then the mean-square, if divided by size-1 then the unbiased or standard deviation. In different cases different ones are used, but at large size the difference is vanishingly small

Yes, it is

 
Maxim Kuznetsov:
is the calculation of unbiased, or standard deviation. In other words, there are two quadratic ones :-) if divided simply by size - then the mean-square, if divided by size-1 then the unbiased or standard deviation. Different ones apply in different cases, but at large size the difference is vanishingly small

Why introduce something that doesn't work at small size and minimally differs at large size?!

You can divide by (size-1) in MathMean. Almost nobody will notice.


ZY R also counts through (size-1)? I checked in MathMean - it divides by size. Wolfram - by (size-1). Stupidity.

Wolfram|Alpha: Computational Knowledge Engine
Wolfram|Alpha: Computational Knowledge Engine
  • www.wolframalpha.com
Wolfram|Alpha is more than a search engine. It gives you access to the world's facts and data and calculates answers across a range of topics, including science, nutrition, history, geography, engineering, mathematics, linguistics, sports, finance, music...
 
fxsaber:

Why introduce something that does not work at small sizes and is minimally different at large sizes!

You can divide by (size-1) in MathMean. Almost nobody will notice.

that's for you to take a course in mathematical statistics :-)) Consider it a divine truth given to us from above and in the form of GOST.