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

 
Maxim Kuznetsov:
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 State Standards

Maple and Mathcad are waving goodbye.

 
fxsaber:

ZY R also counts through (size-1)?

Yes. MathVariance counts sample variance similarly to var() in R.

1.2 MathVariance

The function calculates the variance (second moment) of array elements. In case of an error it returns NaN. An analogue of var() in R.

R:

MQL5:

#include <Math\Stat\Math.mqh>
void OnStart()
  {
//---
   double y[]={1,2,3,4,5,6,7,8,9,10};
   Print(MathVariance(y));
  }



Wolfram:


Excel:


Variance | R Tutorial
  • www.r-tutor.com
An R tutorial on computing the variance of an observation variable in statistics.
 
Quantum:

Yes. MathVariance counts sample variance similarly to var() in R.

R:

MQL5:

Wolfram:

Excel:

Mathcad:

There seems to be no understanding of what Mean Square Deviation is in the systems you cited.

 
fxsaber:

Mathcad:

To calculate sample variance in MathCad try "Var" instead of "var".
 
Quantum:
To calculate sample variance in MathCad try "Var" instead of "var".

How to do it in MQL?

ZY In mathcad there is mean, but there is no Mean. And so it is with many functions. And most people use functions with a small letter. And when something specific is needed, they use capital letters. But in R/Wolfram/Excel, it seems to be the other way round: if there is a possibility to give something specific, it is given by default, and if you need something standard, write it differently. But of course, it's a pity that Math.mqh can't calculate RMS.

 
Alexey Nikolaev:

Either I have something wrong or there is a problem with the empirical density calculation.

Thanks for the message, you are right, there is an error in the normalisation of the empirical density. Attached is the corrected version of Math.mqh.


Files:
Math.mqh  425 kb
 
fxsaber:

How to do it in MQL?

ZY In mathcad there is mean, but there is no Mean. And so it is with many functions. And most people use functions with a small letter. And when you need something specific - with a capital letter. But in R/Wolfram/Excel, it seems to be the other way round: if you can give something specific, it is given by default, and if you need something standard, write it differently. And so, of course, it's a pity that Math.mqh can't calculate RMS.

In general, the function that we have now - MathVariance() - should be called MathUnbiasedVariance(). Because it is a sample unbiased variance (normalised by n-1). I looked in ALGLIB library, it calculates sampled unbiased variance there too.

Good article on the topic.
Выборочная несмещенная дисперсия
Выборочная несмещенная дисперсия
  • votes: 6
  • 2014.08.06
  • Дмитрий Езепов
  • statanaliz.info
Приветствую посетителей блога statanaliz.info. Это очередная статья из рубрики «вариация данных». Сегодня мы продолжаем знакомство со статистической непредсказуемостью. Сразу разочарую: новых показателей вариации сегодня не будет. Зато мы возвращаемся к полюбившейся дисперсии и среднеквадратическому отклонению (корень из дисперсии), и на то...
 
Dennis Kirichenko:

In general, the function that we have now - MathVariance() - should be called MathUnbiasedVariance(). Because it is a sample unbiased variance (normalised by n-1). I looked in the ALGLIB library, it calculates sampled unbiased variance there too.

Will you leave it the bad way?

 
fxsaber:

Will you leave it the bad way?

I will not edit the SB, let the authors do it :-) In principle, you can write your own statistical class based on the SB.

There is another nuance here, imho: when to use biased or unbiased estimation. And what kind of population we are working with - sample or general. The SB tells us right away that we're dealing with a sample. And that's not always the case. Yes, all this is critical when the population is small.

 
Dennis Kirichenko:

I will not edit the SB, let the authors do it :-) In principle, you can write your own statistical class based on the SB.

There is another nuance here, imho: when to use biased or unbiased estimation. And what kind of population we are working with - sample or general. The SB tells us right away that we're dealing with a sample. And that's not always the case. Yes, all this is critical when the population is small.

Well, then don't change the SB, add it. I myself, of course, it is not difficult to correct and write from scratch. The point is that you can pass the code to someone without your bible, because everyone has an SB.