/// <summary>
        /// Вычисление градиента только для  ядра гаусса
        /// </summary>
        /// <param name="distribution"></param>
        public static double Grad(IDistribution distribution, GaussianKernal kernal)
        {
            double min = distribution.GetSampling().Min();
            double max = distribution.GetSampling().Max();
            double x0 = new Random().Next((int)min, (int)max);
            double xi = x0;

            double step = 0.0;
            double YMin = kernal.getDerivative(xi);
            double xNext = xi - EPSSILON * kernal.getDerivative(xi);
            while (kernal.getDerivative(xNext) - kernal.getDerivative(xi) > C)
            {
                step = xi - EPSSILON * kernal.getDerivative(xi) + xi;
                YMin = kernal.getDerivative(xi);
                xi = xNext;
                xNext = xi + step;
            }
            return YMin;
        }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            switch (_currentTab)
            {
                case 0:
                    {
                        //пока яд.ф тестирую только на гнормальном 
                        double mx = Double.Parse(mxTextBox.Text.Trim().Replace('.', ','));
                        double dx = Double.Parse(dxTextBox.Text.Trim().Replace('.', ','));
                        _samplingLenght = Int32.Parse(samplingLengthTextBox.Text.Trim());
                        GausianDistribution d = new GausianDistribution(mx, dx, _samplingLenght);
                        EpanichnikovKernal epan = new EpanichnikovKernal(d);
                        GaussianKernal g = new GaussianKernal(d);
                        Triangular tr = new Triangular(d);
                        _presenter.OnSetDistribution(d,tr);
                        _intervalsCount = Int32.Parse(intervalsLengthTextBox.Text.Trim());
                        _presenter.OnGetBarChart(_intervalsCount);/*отправили в модель*/
                        _FP = mx;
                        _SP = dx;
                        break;
                    }
                case 1:
                    {
                        double alpha = Double.Parse(alphaTetxBox.Text.Trim().Replace('.', ','));
                        double beta = Double.Parse(betaTextBox.Text.Trim().Replace('.', ','));
                        _samplingLenght = Int32.Parse(AmountVibTextBox.Text.Trim().Replace('.', ','));
                        VibrullDistribution vib = new VibrullDistribution(alpha, beta, _samplingLenght);
                        GaussianKernal gk = new GaussianKernal(vib);
                        _presenter.OnSetDistribution(vib,gk);
                        _intervalsCount = Int32.Parse(VIntervalsLenghtTextBox.Text.Trim());
                        _presenter.OnGetBarChart(_intervalsCount);
                        _FP = alpha;
                        _SP = beta;
                        break;
                    }
                case 2:
                    {
                        double inten = Double.Parse(IntenTextBox.Text.Trim().Replace('.', ','));
                        _samplingLenght = Int32.Parse(ExponAmountSapmlingTextBox.Text.Trim());
                        ExponentialDistribution expon = new ExponentialDistribution(inten, _samplingLenght);
                        GaussianKernal gk = new GaussianKernal(expon);
                        _presenter.OnSetDistribution(expon, gk);
                        _intervalsCount = Int32.Parse(ExpAmoubtIntervalsTextBox.Text.Trim());
                        _presenter.OnGetBarChart(_intervalsCount);
                        _FP = inten;
                        _SP = 0;
                        break;
                    }
                case 3:
                    {
                        double mu = Double.Parse(MutextBox.Text.Trim().Replace('.', ','));
                        double lambda = Convert.ToDouble(LambdatextBox.Text.Trim().Replace('.', ','));
                        _samplingLenght = Int32.Parse(VtextBox.Text.Trim());
                        LaplasDistribution laplas = new LaplasDistribution(mu, lambda, _samplingLenght);
                        GaussianKernal gk = new GaussianKernal(laplas);
                        _presenter.OnSetDistribution(laplas, gk);
                        _intervalsCount = Int32.Parse(LAmountTextBox.Text.Trim());
                        _presenter.OnGetBarChart(_intervalsCount);
                        _FP = mu;
                        _SP = lambda;
                        break;
                    }
                case 4:
                    {
                        double a = Double.Parse(aUniformTextBox.Text.Trim().Replace('.', ','));
                        double b = Double.Parse(bUniformTextBox.Text.Trim().Replace('.', ','));
                        _samplingLenght = Int32.Parse(USLenghtTextBox.Text.Trim());
                        UniformDistributions uniforn = new UniformDistributions(a, b, _samplingLenght);
                        GaussianKernal gk = new GaussianKernal(uniforn);
                        _presenter.OnSetDistribution(uniforn, gk);
                        _intervalsCount = Int32.Parse(CoolIntUniform.Text.Trim());
                        _presenter.OnGetBarChart(_intervalsCount);
                        _FP = a;
                        _SP = b;
                        break;
                    }
                case 5:
                    {
                        //double aC = Double.Parse(aCTextBox.Text.Trim().Replace('.', ','));
                        //double muC = Double.Parse(muCTextBox.Text.Trim().Replace('.', ','));
                        //_samplingLenght = Int32.Parse(VCTextBox.Text.Trim());
                        //CauchyDistribution c = new CauchyDistribution(aC, muC, _samplingLenght);
                        //GaussianKernal gk = new GaussianKernal(c);
                        //_presenter.OnSetDistribution(c,gk);
                        //_intervalsCount = Int32.Parse(CCTextBox.Text.Trim());
                        //_presenter.OnGetBarChart(_intervalsCount);
                        //_FP = aC;
                        //_SP = muC;
                        break;
                    }
            }



        }