示例#1
0
文件: Form1.cs 项目: andrewwdk/SAaMM
        private void DoCalculations(double m, double a, double R0)
        {
            Generator     gen   = new Generator(a, m, R0);
            List <double> xList = new List <double>();


            if (uniformRadioButton.Checked)
            {
                double a1 = double.Parse(a1TextBox.Text);
                double b  = double.Parse(bTextBox.Text);
                xList = Distributions.Uniform(gen.GetNext().Take(N), a1, b);
            }
            if (gaussRadioButton.Checked)
            {
                double m1    = double.Parse(m1TextBox.Text);
                double sigma = double.Parse(sigmaTextBox.Text);
                xList = Distributions.Gauss(gen.GetNext().Take(N), m1, sigma);
            }
            if (exponentialRadioButton.Checked)
            {
                double lambda = double.Parse(lambdaTextBox.Text);
                xList = Distributions.Exponential(gen.GetNext().Take(N), lambda);
            }
            if (gammaRadioButton.Checked)
            {
                int    n      = int.Parse(nTextBox.Text);
                double lambda = double.Parse(lambdaTextBox.Text);
                xList = Distributions.Gamma(gen.GetNext().Take(N), lambda, n);
            }
            if (triangleRadioButton.Checked)
            {
                double a1 = double.Parse(a1TextBox.Text);
                double b  = double.Parse(bTextBox.Text);
                xList = Distributions.Triangle(gen.GetNext().Take(N), a1, b);
            }
            if (simphsonRadioButton.Checked)
            {
                double a1 = double.Parse(a1TextBox.Text);
                double b  = double.Parse(bTextBox.Text);
                xList = Distributions.Simpson(gen.GetNext().Take(N), a1, b);
            }

            double Mx, Dx, GAMMAx;

            int[]  countInIntervals = new int[k];
            double xMin, xMax, yMax;

            DoEstimationsCalculations(xList, out Mx, out Dx, out GAMMAx);
            DoDiagramCalculations(xList, countInIntervals, out xMin, out xMax, out yMax);
            DrawDiagram(countInIntervals, xMin, xMax, yMax);
            //CalculateIndirectSign(out indirectSignValue, xList);
            PrintEstimations(Mx, Dx, GAMMAx);
        }
示例#2
0
        public static List<double> Simpson(IEnumerable<double> values, double a, double b)
        {
            List<double> list = new List<double>();
            List<double> uniformList = Distributions.Uniform(values, a / 2, b / 2);
            Random rand = new Random();

            for (int i = 0; i < 100000; i++)
            {
                int index1 = rand.Next(1, 99999);
                int index2 = rand.Next(1, 99999);

                list.Add(uniformList[index1] + uniformList[index2]);
            }

            return list;
        }