Beispiel #1
0
        private static Double Euclidean(IMathPoint p, IMathPoint c)
        {
            DataMiningMath.MetricEquals(p, c);

            Double result = 0;

            for (Int32 i = 0; i < c.CoordinatesCount; i++)
            {
                result += (p[i] - c[i]) * (p[i] - c[i]);
            }
            return(result);
        }
Beispiel #2
0
        private static Double Cityblock(IMathPoint p, IMathPoint c)
        {
            DataMiningMath.MetricEquals(p, c);

            Double result = 0;

            for (Int32 i = 0; i < c.CoordinatesCount; i++)
            {
                result += p[i] < c[i] ? c[i] - p[i] : p[i] - c[i];
            }
            return(result);
        }
Beispiel #3
0
        internal static IMathPoint MeanPoint(IMathPoint p, IMathPoint c)
        {
            DataMiningMath.MetricEquals(p, c);

            IMathPoint meanPoint = c.Clone() as IMathPoint;

            for (Int32 i = 0; i < c.CoordinatesCount; i++)
            {
                meanPoint[i] = 0.5 * (p[i] + c[i]);
            }
            return(meanPoint);
        }
Beispiel #4
0
        private static Double Cosine(IMathPoint p, IMathPoint c)
        {
            DataMiningMath.MetricEquals(p, c);

            Double pc = 0, pp = 0, cc = 0;

            for (Int32 i = 0; i < c.CoordinatesCount; i++)
            {
                pc += p[i] * c[i];
                pp += p[i] * p[i];
                cc += c[i] * c[i];
            }
            return(1 - (pc / System.Math.Sqrt(pp * cc)));
        }