Features & Development

Discrepancies in how scores are rounded for students vs. CSV files

Discrepancies in how scores are rounded for students vs. CSV files

by Glenn Tesler -
Number of replies: 2

The way homework totals are rounded for the student and instructor views within WeBWorK vs. the downloadable score files is different, which can lead to students complaining about score discrepancies. I see that this was reported in 2007, but there wasn't a reply, and apparently the issue is still present:
http://webwork.maa.org/moodle/mod/forum/discuss.php?d=78
Here are more details than in that report, to illustrate the problem and why it arises.

I also reported this in the WeBWorK bugzilla site:
http://bugs.webwork.maa.org/show_bug.cgi?id=3106

Example 1:

rounding_bug_example1.png

The first column of the screenshot shows homework totals
5.00, 3.25, 2.75, 0.00, 4.25.

The problem set totals reported for those same students in [coursename]_totals.csv and s[problemset]scr.csv are different:
5.0, 3.2, 2.8, 0.0, 4.2.

This illustrates both that there is a discrepancy in the number of decimals in the GUI vs. the downloadable files (2 decimals in the GUI vs. 1 in the downloaded scores), and also that the rounding rule is not the conventional "round half up" rule (2.75 is rounded up to 2.8, while 3.25 and 4.25 are rounded down to 3.2 and 4.2).

I suggest that in all places where scores are displayed to 1 or 2 decimals (rather than full precision) or in 01-99 format, you change them to consistently use two decimals (never one) and that you round using a consistent method. Preferably floor(100.0*x+.5)/100.0 instead of sprintf("%.2f",x) (or for one decimal, replace 100.0 by 10.0).

The 1 decimal vs. 2 discrepancy is in every problem set. The extent of the rounding halves issue varies by problem set due to which denominators arise in fractional points. It's very likely to happen in a 4 part problem with weight 1 (1 part right and 3 parts wrong gives 0.25 points), but it can also happen in other ways.


Example 2:
rounding_bug_example2.png

Make a one problem set consisting of this 8-part problem, and assign it a weight of 1:
Library/272/setStewart14_5/problem_3.pg

Enter the correct answer for one part and leave the other parts blank, for a score 0.125. This is both the problem total and the homework total. It is rounded and reported in three unequal ways:

(a) The screenshot shows "13" percent on the problem (it multiplies .125 by 100 and uses "round half up").

(b) The same screenshot shows the homework total is "0.12" (which uses "round half to even" with 2 decimals).

(c) The homework total in the downloaded score files is "0.1" (which uses "round half to even" with 1 decimal).


Details on rounding methods:

The normal rule of rounding a 5 up is "Round half up". WeBWorK appears to use "Round half to even" for homework totals, which would be explained if you use
sprintf("%.1f",x) or sprintf("%.2f",x) for 1 or 2 decimals.
http://en.wikipedia.org/wiki/Rounding#Round_half_up
http://en.wikipedia.org/wiki/Rounding#Round_half_to_even

Here's a demo to show that they're different. The discrepancies arise due to different rounding methods combined with the fact that some decimal numbers can't be precisely represented in double precision. Similar issues arise when rounding from many decimals to two decimals.

xsprintf("%.1f",x)floor(10.0*x+0.5)/10.0
0.050.10.1
0.150.10.2   (discrepancy)
0.250.20.3   (discrepancy)
0.350.30.4   (discrepancy)
0.450.50.5
0.550.60.6
0.650.70.7
0.750.80.8
0.850.80.9   (discrepancy)
0.950.9

1.0   (discrepancy)

In reply to Glenn Tesler

Re: Discrepancies in how scores are rounded for students vs. CSV files

by Arnold Pizer -
Hi Glenn,

Thanks for your very through and helpful post.  I'll look into this.

Arnie
In reply to Glenn Tesler

Re: Discrepancies in how scores are rounded for students vs. CSV files

by Arnold Pizer -
This is fixed in pull request 513 (https://github.com/openwebwork/webwork2/pull/513).

This should be incorporated into WeBWorK 2.10.

Thanks for the very informative bug report.

Arnie