- Timestamp:
- 07/30/12 11:08:14 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/HoeffdingsDependenceCalculator.cs
r7969 r8355 103 103 104 104 /// <summary> 105 /// Calculates midranks. Source: Numerical Recipes in C. 105 /// Calculates midranks. Source: Numerical Recipes in C. p 642 106 106 /// </summary> 107 107 /// <param name="w">Sorted array of elements, replaces the elements by their rank, including midranking of ties</param> … … 117 117 } else { 118 118 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); 121 121 int k; 122 for (k = i; k < j - 1; k++) w[k] = rank; // set the rank for all tied entries122 for (k = i; k < j; k++) w[k] = rank; // set the rank for all tied entries 123 123 i = j; 124 124 } 125 125 } 126 126 127 if (i == n - 1) w[n - 1] = n - 1; // if the last element was not tied, this is its rank127 if (i == n - 1) w[n - 1] = n; // if the last element was not tied, this is its rank 128 128 } 129 129 }
Note: See TracChangeset
for help on using the changeset viewer.