Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/30/12 11:08:14 (12 years ago)
Author:
gkronber
Message:

#1292: fixed bugs in HoeffdingsDependenceCalculator, added test cases for HoeffdingsDependenceCalculator

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/HoeffdingsDependenceCalculator.cs

    r7969 r8355  
    103103
    104104    /// <summary>
    105     /// Calculates midranks. Source: Numerical Recipes in C.
     105    /// Calculates midranks. Source: Numerical Recipes in C. p 642
    106106    /// </summary>
    107107    /// <param name="w">Sorted array of elements, replaces the elements by their rank, including midranking of ties</param>
     
    117117        } else {
    118118          int j;
    119           for (j = i + 1; j < n && w[j] <= w[i]; j++) ; // how far does it go (<= effectively means == as w must be sorted)
    120           double rank = 0.5 * (i + j - 1);
     119          for (j = i + 1; j < n && w[j] <= w[i]; j++) ; // how far does it go (<= effectively means == as w must be sorted, side-step equality for double values)
     120          double rank = 1 + 0.5 * (i + j - 1);
    121121          int k;
    122           for (k = i; k < j - 1; k++) w[k] = rank; // set the rank for all tied entries
     122          for (k = i; k < j; k++) w[k] = rank; // set the rank for all tied entries
    123123          i = j;
    124124        }
    125125      }
    126126
    127       if (i == n - 1) w[n - 1] = n - 1;   // if the last element was not tied, this is its rank
     127      if (i == n - 1) w[n - 1] = n;   // if the last element was not tied, this is its rank
    128128    }
    129129  }
Note: See TracChangeset for help on using the changeset viewer.