ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  ArrayMath quantile not produce precise value.
Posted by ET on Sep-17-2015 15:19
Hi Peter,

Could you please advise if I used the ArrayMath utility correctly.

I was trying to calculate Q1 value by following measurements:

0.000000000103625
0.000000000101988
0.0000000000999198
0.000000000102222
0.000000000101326
0.0000000000998544
0.000000000100113
0.000000000100956
0.000000000101486
0.000000000100415
0.000000000103683
0.000000000101586
0.000000000100645
0.00000000010133
0.000000000101542
0.0000000000979571
0.000000000101268
0.00000000010168
0.000000000104145
0.000000000100587

Via .Net codes:
double value_q1 = new ArrayMath(data.ToArray()).percentile(25);

I got a value of: value_q1 = 0.000000000100544

By right, standard statistical formula should be giving value: 0.000000000100458

Please comment. Thanks.

  Re: ArrayMath quantile not produce precise value.
Posted by Peter Kwan on Sep-17-2015 21:57
Hi ET,

I have just tried using Excel, and the result from Excel is 0.000000000100544, which agrees
to ChartDirector.

Would you mind to clarify which standard statistical formula you are using, and how does it
compute to 0.000000000100458?

Regards
Peter Kwan

  Re: ArrayMath quantile not produce precise value.
Posted by ET on Sep-18-2015 02:06
Hi Peter,

I used one of the online tool to do the quick run:

http://www.alcula.com/calculators/statistics/quartiles/

Not sure if the formula implemented differ to ChartDirector.

Thanks.

  Re: ArrayMath quantile not produce precise value.
Posted by ET on Sep-18-2015 08:04
Hi Peter,

I also run similar distribution analysis against JMP statiscal tool and the result return as
per the same measurements return following:

100.0%   maximum 1.04145e-10
99.5%         1.04145e-10
97.5%         1.04145e-10
90.0%         1.036772e-10
75.0%    quartile         1.01911e-10
50.0%    median         1.01328e-10
25.0%    quartile         1.00458e-10
10.0%         9.986094e-11
2.5%                 9.79571e-11
0.5%                 9.79571e-11
0.0%      minimum 9.79571e-11

  Re: ArrayMath quantile not produce precise value.
Posted by ET on Sep-18-2015 09:09
Hi Peter,

I made few more study and it seem like ArrayMath implementation using an algorithm of
(N-1) for the calculation whereas other statistical tool using (N+1)

Even Excel never version have new functions for (N+1).

http://datapigtechnologies.com/blog/index.php/why-excel-has-multiple-quartile-functions-
and-how-to-replicate-the-quartiles-from-r-and-other-statistical-packages/

Wondering if there is any extension for ArrayMath to use (N+1) instead?

Thanks.

  Re: ArrayMath quantile not produce precise value.
Posted by Peter Kwan on Sep-18-2015 22:20
Hi ET,

Thanks for your useful information. We did not realize there are so many methods to
compute quartiles, and they all give different results. Then I search Wiki on "percentiles",
and found that there are even more methods. The method used by ChartDirector is the
same as the default method used by Excel.

Anyway, although it is not mentioned clearly in the "Why Excel has two quartiles" page, I
realize the two additional indexes used in the (N+1) method are just the duplicates of the
minimum and maximum values. It is because if the percentile line is less than the index 1,
the percentile value will be the minimum value at index 1. So the value at index 0 must be
equivalent to the value at index 1. Similarly, the value at N+1 is equivalent to the value at
N.

So to obtain the same result as the (N+1) method, you can add two extra values to your
data equal to the minimum and the maximum values of your data. For example, if you have
20 points, you can duplicate the maximum and minimum data values so that there are 22
points. The percentile would then be equivalent to the (N+1) method.

Regards
Peter Kwan

  Re: ArrayMath quantile not produce precise value.
Posted by ET on Sep-21-2015 08:33
Thanks Peter for the clarification. I will go ahead with the workaround as you suggested.