Changeset 2063


Ignore:
Timestamp:
Oct 17, 2011, 1:14:03 PM (12 years ago)
Author:
tjeerd@…
Message:

VIS-43, corrected error in median calculation of even-length lists

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/dbnp/visualization/VisualizeController.groovy

    r2061 r2063  
    984984        def listSize = listOfValues.size();
    985985
     986        def objReturn = null;
     987
    986988                if( listSize > 0 ) {
    987989            def listHalf = (int) Math.abs(listSize/2);
    988990            if(listSize%2==0) {
    989991                // If the list is of an even size, take the mean of the middle two value's
    990                 return ["value": (listOfValues.get(listHalf)+listOfValues.get(listHalf-1))/2];
     992                objReturn = (listOfValues.get(listHalf)+listOfValues.get(listHalf-1))/2;
    991993            } else {
    992994                // If the list is of an odd size, take the middle value
    993                 return ["value": listOfValues.get(listHalf-1)];
    994             }
    995         } else
    996                         return ["value": null];
     995                objReturn = listOfValues.get(listHalf);
     996            }
     997        }
     998
     999                return ["value": objReturn];
    9971000        }
    9981001
Note: See TracChangeset for help on using the changeset viewer.