Geometric Mean calculation - MQL4 advice needed

 
I refer you to http://www.buzzardsbay.org/geomean.htm which shows a few ways to do the calculation of geometric mean.

My issue is how to do in MQL4

Am not really into maths as such so.... over to you! OK?

Many thanks
Tim
 
I refer you to http://www.buzzardsbay.org/geomean.htm which shows a few ways to do the calculation of geometric mean.

My issue is how to do in MQL4

Am not really into maths as such so.... over to you! OK?

Many thanks
Tim


! using one of the examples in the above reference site I did following:

int start(){
double d;
d=MathLog(6);
d+=MathLog(50);
d+=MathLog(9);
d+=MathLog(1200);
Print("gm = ",MathExp(d/4));
return (0);
}

result: ....................
2005.11.16 17:05:33 geomean AUDUSD,Daily: gm = 42.4264

I guess hack * 100 eventually won the day :)

Saw another site after I'd posted my query, it said that:
1. sum logs of y data points -> b
2. get arithmetical mean of b: b/y -> am
3. get antilog of am: exp(am) -> geometric mean

Woweeeee, I not understand logs, antilogs but hey... it works!!!

Oh yes - my reason for this is to get a 'mean' that is not effected by large or small data points on the left/right of the dataset - as this would have the effect of skewing the mean towards these large/small datums.
I did google on calculating 'mean' and the geometric mean filters/softens the impact of for example a few large numbers in a dataset of say, smallish numbers (much like the example above where 1200 is LARGE and 6,50,9 are smal)

The arithmetical mean for (6+50+9+1200)/4 -> 1265/4 -> 316.25
and compared to the geometric mean of 42.4264 is very different.

I've got all excited over nothing really - but now 'n then is nice to 'perhaps' get something right (lol)

ANY refinements or comments gratefully accepted - as I said, maths is NOT my area...
 
I refer you to http://www.buzzardsbay.org/geomean.htm which shows a few ways to do the calculation of geometric mean.

My issue is how to do in MQL4

Am not really into maths as such so.... over to you! OK?

Many thanks
Tim


! using one of the examples in the above reference site I did following:

int start(){
double d;
d=MathLog(6);
d+=MathLog(50);
d+=MathLog(9);
d+=MathLog(1200);
Print("gm = ",MathExp(d/4));
return (0);
}

result: ....................
2005.11.16 17:05:33 geomean AUDUSD,Daily: gm = 42.4264

I guess hack * 100 eventually won the day :)

Saw another site after I'd posted my query, it said that:
1. sum logs of y data points -> b
2. get arithmetical mean of b: b/y -> am
3. get antilog of am: exp(am) -> geometric mean

Woweeeee, I not understand logs, antilogs but hey... it works!!!

Oh yes - my reason for this is to get a 'mean' that is not effected by large or small data points on the left/right of the dataset - as this would have the effect of skewing the mean towards these large/small datums.
I did google on calculating 'mean' and the geometric mean filters/softens the impact of for example a few large numbers in a dataset of say, smallish numbers (much like the example above where 1200 is LARGE and 6,50,9 are smal)

The arithmetical mean for (6+50+9+1200)/4 -> 1265/4 -> 316.25
and compared to the geometric mean of 42.4264 is very different.

I've got all excited over nothing really - but now 'n then is nice to 'perhaps' get something right (lol)

ANY refinements or comments gratefully accepted - as I said, maths is NOT my area...




It appears that there is no difference between Geometric and Arithmetic Averages.
Reason: