c# - why subtract 0.5 and then *2 in that code......by JAKEDREW(http://www.jakemdrew.com/blog/RgbProjector.htm -
http://www.jakemdrew.com/blog/rgbprojector.htm
private static double calculateprojectionsimilarity(double[] source, double[] compare) { if (source.length != compare.length) { throw new argumentexception(); } var frequencies = new dictionary(); ////calculate frequencies (var = 0; < source.length; i++) { var difference = source[i] - compare[i]; difference = math.round(difference, 2); difference = math.abs(difference); if (frequencies.containskey(difference)) { frequencies[difference] = frequencies[difference] + 1; } else { frequencies.add(difference, 1); } } var deviation = frequencies.sum(value => (value.key * value.value)); ////calculate "weighted mean" ////http://en.wikipedia.org/wiki/weighted_mean deviation /= source.length; ////maximize scale deviation = (0.5 - deviation) * 2; return deviation; }
Comments
Post a Comment