Ejemplo n.º 1
0
        /// <summary>
        /// Получает массив значений яденой функции
        /// </summary>
        /// <returns></returns>
        public KernalFunctionValues[] GetKernalFunctionValues(double dt)
        {
            int index = 0;
            List<KernalFunctionValues> values = new List<KernalFunctionValues>();
            double min = _distribution.GetSampling().Min();
            double max = _distribution.GetSampling().Max();
            double[] kerf = _kernal.GetKernalDensityFunctionValues();//получаем массив значений 
            for (double x = min; x < max;x+=dt )
            {
                KernalFunctionValues value = new KernalFunctionValues(x, kerf.ElementAt(index));
                values.Add(value);
                index++;
                if(index==kerf.Length)
                {
                    break;//
                }
            }
                return values.ToArray();

        }
Ejemplo n.º 2
0
        public List<KernalFunctionValues> Noise(List<DensityFunctionValue> defaultValues)
        {
            List<KernalFunctionValues> averages = new List<KernalFunctionValues>();
            try
            {
                List<KernalFunctionValues> res = new List<KernalFunctionValues>();//с шумом
                Random r = new Random();
                int idx = 0;
                foreach (DensityFunctionValue f in defaultValues)
                {
                    KernalFunctionValues k = new KernalFunctionValues(f.X, f.Y + r.NextDouble());
                    res.Add(k);
                    idx++;
                }
                
                // double[] aver = new double[res.Count];

                double sum = 0.0;
                double Xvalue = 0.0;//коррдината Х первой точки из окна суммирования 
                for (int i = 0; i < res.Count; i++)
                {
                    for (int j = i; j < window + i; j++)
                    {
                        sum += res.ElementAt(j).Y;
                        if (j == i)
                        {
                            Xvalue = sum += res.ElementAt(j).X;
                        }
                    }
                    KernalFunctionValues noNoise = new KernalFunctionValues(Xvalue, sum / window);
                    averages.Add(noNoise);
                    sum = 0.0;
                }
            }
            catch (ArgumentOutOfRangeException)
            {
                return averages;
            }

            return averages;
        }