24-09-2015, 01:13 AM

I have detected a bug in the Statistics 1App of the HP Prime Calculator.

The bug affects the calculation of the first and third Quartile in case where the number of data points is EVEN:

Let us take a simple example of the following data set:

n Value

1 1.1

2 2.7

3 3.2

4 3.5

5 4.6

6 5.5

7 6.4

8 6.7

9 8.4

10 9.3

Measures of position

First quartile (Q1)

Every group of data has three quartiles. If you sort the data from smallest to largest, the first 25% of the data is less than

or equal to the first quartile.

To calculate quartiles, first order the data from smallest to largest. The first quartile (Q1) is the observation at position

(N + 1) / 4, where N is the number of nonmissing observations. If the position is not an integer, interpolation is used.

For example, suppose N=10. Then (10 + 1)/4 = 2.75, and Q1 is between the second and third observations (call them x(2) and x(3)), one-fourth of the way up.

Thus, Q1 = x(2) + 0.75(x(3) - x(2)).

In our example:

2.7 + 0.75 * (3.2 - 2.7) = 3.075 and NOT 3.2 as the calculator suggests

Third quartile (Q3)

Every group of data has three quartiles. If you sort the data from smallest to largest, the first 75% of the data is less than or equal to the third quartile and 25% of the data is greater than or equal to the third quartile.

To calculate quartiles, first order the data from smallest to largest. The third quartile (Q3) is the observation at position

3(N + 1) / 4, where N is the number of nonmissing observations. If the position is not an integer, interpolation is used.

For example, suppose N=10. Then 3(10 + 1)/4 = 8.25, Q3 = x(8) + 0.25(x(9) - x(8)), where x(8) and x(9) are the eighth and

ninth observations.

In our example:

6.7 + 0.25 * (8.4 - 6.7) = 7.175 and NOT 6.7 as the calculator suggests

This means that if one calculates the interquartile range for a set of data where n is EVEN, this will also be wrong.

AND the Box & Whisker plot for these data will also be wrong, as indeed it is!

I also found, up to now, five HP Prime commands that do quite produce the result that the Help file promises...

When I finish the program the calculates the TRUE quartiles as well as the Skewness and Kurtosis I shall flog this online.

Remember: never take a statement at face value and:

"Nothing elevates the Spirit more than striving for perfection."

Bye for nowhttp://www.cg.ensmp.fr/bibliotheque/cgi-bin/public/bibli_index.cg, from,

The bug affects the calculation of the first and third Quartile in case where the number of data points is EVEN:

Let us take a simple example of the following data set:

n Value

1 1.1

2 2.7

3 3.2

4 3.5

5 4.6

6 5.5

7 6.4

8 6.7

9 8.4

10 9.3

Measures of position

First quartile (Q1)

Every group of data has three quartiles. If you sort the data from smallest to largest, the first 25% of the data is less than

or equal to the first quartile.

To calculate quartiles, first order the data from smallest to largest. The first quartile (Q1) is the observation at position

(N + 1) / 4, where N is the number of nonmissing observations. If the position is not an integer, interpolation is used.

For example, suppose N=10. Then (10 + 1)/4 = 2.75, and Q1 is between the second and third observations (call them x(2) and x(3)), one-fourth of the way up.

Thus, Q1 = x(2) + 0.75(x(3) - x(2)).

In our example:

2.7 + 0.75 * (3.2 - 2.7) = 3.075 and NOT 3.2 as the calculator suggests

Third quartile (Q3)

Every group of data has three quartiles. If you sort the data from smallest to largest, the first 75% of the data is less than or equal to the third quartile and 25% of the data is greater than or equal to the third quartile.

To calculate quartiles, first order the data from smallest to largest. The third quartile (Q3) is the observation at position

3(N + 1) / 4, where N is the number of nonmissing observations. If the position is not an integer, interpolation is used.

For example, suppose N=10. Then 3(10 + 1)/4 = 8.25, Q3 = x(8) + 0.25(x(9) - x(8)), where x(8) and x(9) are the eighth and

ninth observations.

In our example:

6.7 + 0.25 * (8.4 - 6.7) = 7.175 and NOT 6.7 as the calculator suggests

This means that if one calculates the interquartile range for a set of data where n is EVEN, this will also be wrong.

AND the Box & Whisker plot for these data will also be wrong, as indeed it is!

I also found, up to now, five HP Prime commands that do quite produce the result that the Help file promises...

When I finish the program the calculates the TRUE quartiles as well as the Skewness and Kurtosis I shall flog this online.

Remember: never take a statement at face value and:

"Nothing elevates the Spirit more than striving for perfection."

Bye for nowhttp://www.cg.ensmp.fr/bibliotheque/cgi-bin/public/bibli_index.cg, from,