History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: SAK-12827
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Critical Critical
Assignee: Unassigned
Reporter: Stephen Marquard
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Sakai

Standard deviation calculation is incorrect

Created: 25-Jan-2008 04:07   Updated: 22-Oct-2008 20:49
Component/s: Tests & Quizzes (Samigo)
Affects Version/s: 2.5.0
Fix Version/s: 2.5.0, 2.4.x, 2.6.0-alpha-01

Time Tracking:
Not Specified

File Attachments: 1. File SAK-12827-stdev.diff (1 kb)


2.4.x Status: Resolved
2.5.x Status: None
2.6.x Status: None


 Description  « Hide
The standard deviation calculation for test scores is incorrect. See http://hubpages.com/hub/stddev for how to calculate it correctly.

Note that there are 2 formulas which differ by whether to divide the sums by n or n-1. n-1 is preferred here for consistency with Excel and for example cited here: http://davidmlane.com/hyperstat/A16252.html

See also http://en.wikipedia.org/wiki/Standard_deviation (which refers to n rather than n-1).

The code in samigo thus has 2 errors:

- total is using the existing total score value as a starting point (instead of 0)
- the square root calculation is by n-1 rather than n.

/**
   * Calculate standard Deviation
   *
   * @param scores array of scores
   * @param mean the mean
   * @param total the total
   *
   * @return the standard deviation
   */
  private static double calStandDev(double[] scores, double mean, double total)
  {
    for(int i = 0; i < scores.length; i++)
    {
      total = total + ((scores[i] - mean) * (scores[i] - mean));
    }

    return Math.sqrt(total / scores.length);
  }


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Stephen Marquard - 25-Jan-2008 05:46
Patch which fixes standard deviation calculation. Verified on 2-5-x production build against calculations in MS Excel (Office 2003) on the spreadsheet export.


Stephen Marquard - 25-Jan-2008 05:47
The attached patch needs to be committed to trunk, then merged into 2-5-x and probably also 2-4-x branches.

Megan May - 30-Jan-2008 11:35
Update from Karen Tsao - set it up in my local environment. We are reviewing it now and will update the bug with our feedback.

Karen Tsao - 30-Jan-2008 17:29
For trunk:

commit -m "SAK-12827" C:/sakai_trunk/sam/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/evaluation/HistogramListener.java
    Sending sakai_trunk/sam/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/evaluation/HistogramListener.java
    Transmitting file data ...
    Committed revision 40643.

Karen Tsao - 30-Jan-2008 17:31
Stephen,

I have checked into trunk. Please verify it in QA nightly instance. If you think it is good, please assign 2.5.x Branch Manager. I will also merge this back to 2.4.x once you say it's good to go. Thanks.

Stephen Marquard - 31-Jan-2008 01:56
Pls merge to 2-5-x and also the SAK-12065 sam branch, then assign to 2-4-x branch manager.

David Horwitz - 31-Jan-2008 03:54
merged into 2-5-x with r40725

Filter Maintainer - 08-Aug-2008 06:04
2.5.0 QA has been completed. Unfortunately, there were not resources available to specifically test this issue. If you find this to still be a problem in the latest release (at this point 2.5.2), please reopen the JIRA and add the latest affects version.