Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/26/09 15:55:11 (15 years ago)
Author:
mkommend
Message:

corrected median implementation (ticket #808)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.DataAnalysis/3.2/Statistics.cs

    r2136 r2535  
    163163      if (values.Length == 0) throw new InvalidOperationException();
    164164      int n = values.Length;
    165       if (n == 0)
    166         return 0;
    167 
    168165      double[] sortedValues = new double[n];
    169166
     
    175172        return sortedValues[n / 2];
    176173      } else {
    177         return (sortedValues[n / 2] + sortedValues[n / 2 + 1]) / 2.0;
     174        return (sortedValues[(n / 2)-1] + sortedValues[n / 2 ]) / 2.0;
    178175      }
    179176    }
Note: See TracChangeset for help on using the changeset viewer.