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
for (var i = 0; i < 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;
}