Beispiel #1
0
        private static double GetNadarayaWatsonMiddlePoint(IList <double> source, NadarayaWatsonVariant variant)
        {
            switch (variant)
            {
            case NadarayaWatsonVariant.Subsitution:
                return((Averages.Central(source, 50).Value + Averages.Median(source).Value) / 2.0);

            case NadarayaWatsonVariant.NoiseCoursing:
                return((Averages.Maximum(source).Value - Averages.Minimum(source).Value) / 2.0);
            }

            return(double.NaN);
        }
Beispiel #2
0
        public static IList <double> NearestNeighbors(IList <IList <double> > orderedSet, int kNN = 8)
        {
            if (orderedSet == null || orderedSet.Count == 0 || kNN <= 0)
            {
                return(new List <double>().AsReadOnly());
            }

            IList <IList <double> > operative = new List <IList <double> >();

            Lists.Concat(operative, Lists.Get(kNN, 1, 0.0));
            Lists.Concat(operative, orderedSet);
            IList <double> neighbors = new List <double>();
            IList <double> currentSet;

            for (int i = kNN; i < orderedSet.Count + kNN; i++)
            {
                currentSet = Lists.GetCopyConcatenated(operative, i - kNN, i + 1);
                neighbors.Add(Averages.Median(currentSet).Value);
            }

            return(neighbors);
        }