Пример #1
0
        public int GetLongestDimension(DimWeight dw)
        {
            //return GetHighestVarianceDimension(dw);

            int    longestDim    = 0;
            double longestDimLen = Double.MinValue;

            for (int i = 0; i < dw.NumDim; i++)
            {
                double mincur = Double.MaxValue;
                double maxcur = Double.MinValue;

                foreach (var point in points)
                {
                    if (point.Values[i] > maxcur)
                    {
                        maxcur = point.Values[i];
                    }
                    if (point.Values[i] < mincur)
                    {
                        mincur = point.Values[i];
                    }
                }
                if (((maxcur - mincur) * dw.Pdf[i]) > longestDimLen)
                {
                    longestDim    = i;
                    longestDimLen = ((maxcur - mincur) * dw.Pdf[i]);
                }
            }
            return(longestDim);
        }
Пример #2
0
        public double GetMeanDistance(Point p, DimWeight dw)
        {
            double sum = 0;

            foreach (var myp in points)
            {
                sum += myp.ComputeDistance(p, dw);
            }

            return(sum / points.Count());
        }
        public double ComputeDistance(Point other, DimWeight dw)
        {
            if (NumDim != other.NumDim || NumDim != dw.NumDim)
            {
                return(-1);
            }

            double distSq = 0;

            for (int i = 0; i < NumDim; i++)
            {
                distSq += Math.Pow((other.Values[i] - Values[i]) * dw.Pdf[i] * NumDim, 2);
            }

            return(Math.Sqrt(distSq));
        }
Пример #4
0
        public int GetHighestVarianceDimension(DimWeight dw)
        {
            int    longestDim    = 0;
            double longestDimLen = Double.MinValue;

            for (int i = 0; i < dw.NumDim; i++)
            {
                List <double> d = new List <double>();
                foreach (var point in points)
                {
                    d.Add(point.Values[i]);
                }
                var std = stdev(d) * dw.Pdf[i];
                if (std > longestDimLen)
                {
                    longestDim    = i;
                    longestDimLen = std;
                }
            }
            return(longestDim);
        }
 public PointCompare(DimWeight dw, Point p)
 {
     Dw = dw;
     P  = p;
 }