Пример #1
0
        /* private void button1_Click(object sender, EventArgs e)
         * {
         *   for (int i = 0; i < dataGridView1.ColumnCount; i++)
         *   {
         *       for (int j = 0; j < dataGridView1.RowCount; j++)
         *       {
         *           double val1 = Convert.ToDouble(dataGridView1.Rows[j].Cells[i].Value);
         *           if (!nZvalue.Contains(val1))
         *           {
         *               nZvalue.Add(val1);
         *           }
         *       }
         *       Ztype.Add(AnalysisClass.getScale(nZvalue.Count));
         *       nZvalue.Clear();
         *   }
         *   for (int i = 0; i < dataGridView1.RowCount; i++)
         *   {
         *       double val1 = Convert.ToDouble(dataGridView1.Rows[i].Cells[0].Value);
         *       nZvalue.Add(val1);
         *   }
         *   resTypeReg.Text = AnalysisClass.getReggressionMethod(Ztype, comboBox2.Text, nZvalue);
         *   nZvalue.Clear();
         *
         * }*/

        private void AnalizMetod_Click(object sender, EventArgs e)
        {
            Ztype.Clear();
            nZvalue.Clear();
            if ((dataGridView1.Columns.Count - 1) * 3 <= dataGridView1.RowCount)
            {
                for (int i = 0; i < dataGridView1.ColumnCount; i++)
                {
                    for (int j = 0; j < dataGridView1.RowCount; j++)
                    {
                        double val1 = Convert.ToDouble(dataGridView1.Rows[j].Cells[i].Value);
                        if (!nZvalue.Contains(val1))
                        {
                            nZvalue.Add(val1);
                        }
                    }
                    Ztype.Add(AnalysisClass.getScale(nZvalue.Count));
                    nZvalue.Clear();
                }
                for (int i = 0; i < dataGridView1.RowCount; i++)
                {
                    double val1 = Convert.ToDouble(dataGridView1.Rows[i].Cells[0].Value);
                    nZvalue.Add(val1);
                }
                string[] words = AnalysisClass.getCurrentReggressionMethod(Ztype, nZvalue).Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
                richTextBox1.Text = string.Join(Environment.NewLine, words);
                nZvalue.Clear();
            }
            else
            {
                richTextBox1.Text = "Выборка слишком мала для точного анализа.";
            }
        }
Пример #2
0
        private void calculateBtn_Click(object sender, EventArgs e)
        {
            List <Double> xUniqVals = new List <Double>();
            List <Double> yUniqVals = new List <Double>();

            for (int i = 0; i < dataGV_data.RowCount - 1; i++)
            {
                Double val1 = Convert.ToDouble(dataGV_data.Rows[i].Cells[0].Value);
                Double val2 = Convert.ToDouble(dataGV_data.Rows[i].Cells[1].Value);
                if (!xUniqVals.Contains(val1))
                {
                    xUniqVals.Add(val1);
                }
                if (!yUniqVals.Contains(val2))
                {
                    yUniqVals.Add(val2);
                }
                xVals.Add(val1);
                yVals.Add(val2);
            }
            volumeTxtBx.Text     = (dataGV_data.RowCount - 1).ToString();
            xUniqCountTxtBx.Text = xUniqVals.Count.ToString();
            yUniqCountTxtBx.Text = yUniqVals.Count.ToString();
            xSchaleTxtBx.Text    = AnalysisClass.getScale(xUniqVals.Count);
            ySchaleTxtBx.Text    = AnalysisClass.getScale(yUniqVals.Count);

            meanXTxtBx.Text   = MathNet.Numerics.Statistics.Statistics.Mean(xVals).ToString();
            stddevXTxtBx.Text = MathNet.Numerics.Statistics.Statistics.PopulationStandardDeviation(xVals).ToString();

            meanYTxtBx.Text   = MathNet.Numerics.Statistics.Statistics.Mean(yVals).ToString();
            stddevYTxtBx.Text = MathNet.Numerics.Statistics.Statistics.PopulationStandardDeviation(yVals).ToString();

            Double corrVal = MathNet.Numerics.Statistics.Correlation.Spearman(xVals, yVals);

            corrValTxtBx.Text = corrVal.ToString();
            int freedomDegree = xVals.Count - 2;

            if (freedomDegree >= 5 && freedomDegree <= 30)
            {
                critValTxtBx.Text      = CorrelationUtils.getSpearmanCriticalValue(freedomDegree, float.Parse("0,05")).ToString();
                isCorrelatedTxtBx.Text = CorrelationUtils.getSpearmanSignificant(freedomDegree, corrVal);
            }
            else
            {
                critValTxtBx.Text      = "не рассчитано";
                isCorrelatedTxtBx.Text = CorrelationUtils.getSpearmanSignificant(freedomDegree, corrVal);
            }

            cl.CreateGraph(zg1, dataGV_data);
            cl.CreateGraph2(zg2, dataGV_data);
            cl.CreateGraph3(zg3, dataGV_data);

            xVals.Clear();
            yVals.Clear();
            xUniqVals.Clear();
            yUniqVals.Clear();
        }
Пример #3
0
        private void variableanalysisbutton_Click(object sender, EventArgs e)
        {
            clear();
            if (comboBox1.Text.Equals("Зависимая переменная"))
            {
                number_cols = 0;
            }
            else
            {
                string resultString = string.Join(string.Empty, Regex.Matches(comboBox1.Text, @"\d+").OfType <Match>().Select(m => m.Value));
                int.TryParse(resultString, out number_cols);
            }
            for (int i = 0; i < dataGridView1.RowCount; i++)
            {
                double val1 = Convert.ToDouble(dataGridView1.Rows[i].Cells[number_cols].Value);

                if (!valuesUQ.Contains(val1))
                {
                    valuesUQ.Add(val1);
                }
                values.Add(val1);
            }
            Numberofvalues.Text     = values.Count.ToString();
            numberuniquevalues.Text = valuesUQ.Count.ToString();
            scaletype.Text          = AnalysisClass.getScale(valuesUQ.Count);



            Accord.Statistics.Distributions.Univariate.NormalDistribution normDist =
                Accord.Statistics.Distributions.Univariate.NormalDistribution.Standard;


            if (!scaletype.Text.Equals("дихотомическая"))
            {
                Accord.Statistics.Testing.KolmogorovSmirnovTest kstX =
                    new Accord.Statistics.Testing.KolmogorovSmirnovTest(values.ToArray(), normDist);
                TypeDistr.Text         = AnalysisClass.getDistributionScale(kstX.Significant);
                avg.Text               = Math.Round(MathNet.Numerics.Statistics.Statistics.Mean(values), 3).ToString();
                standarddeviation.Text = Math.Round(MathNet.Numerics.Statistics.Statistics.PopulationStandardDeviation(values), 3).ToString();
                skewness.Text          = Math.Round(MathNet.Numerics.Statistics.Statistics.PopulationSkewness(values), 3).ToString();
                piko.Text              = Math.Round(MathNet.Numerics.Statistics.Statistics.PopulationKurtosis(values), 3).ToString();
                plotting.CreateGraphNormDistr(zg1, values, valuesUQ);
            }
            else
            {
                TypeDistr.Text         = "Невозможно определить определить";
                avg.Text               = "Невозможно определить определить";
                standarddeviation.Text = "Невозможно определить определить";
                skewness.Text          = "Невозможно определить определить";
                piko.Text              = "Невозможно определить определить";
                zg1.GraphPane.CurveList.Clear();
                zg1.GraphPane.GraphObjList.Clear();
                zg1.Refresh();
            }
        }
Пример #4
0
        private void generateBtn_Click(object sender, EventArgs e)
        {
            double[] xVal = AnalysisClass.generateValues(xScaleCmbBx.Text,
                                                         xDistrCmbBx.Text, Convert.ToInt32(numericUpDown1.Value));
            double[] yVal = AnalysisClass.generateValues(yScaleCmbBx.Text,
                                                         yDistrCmbBx.Text, Convert.ToInt32(numericUpDown1.Value));

            dataGV_data.Columns[0].Name       = "X";
            dataGV_data.Columns[0].HeaderText = "X"; // вывод имен столбцов
            dataGV_data.Columns[1].Name       = "Y";
            dataGV_data.Columns[1].HeaderText = "Y"; // вывод имен столбцов

            dataGV_data.Rows.Clear();
            for (int i = 0; i < numericUpDown1.Value; i++)
            {
                dataGV_data.Rows.Add(xVal[i], yVal[i]);
            }
        }
Пример #5
0
        private void doAnalysisBtn_Click(object sender, EventArgs e)
        {
            List <Double> xUniqVals = new List <Double>();
            List <Double> yUniqVals = new List <Double>();

            for (int i = 0; i < dataGV_data.RowCount - 1; i++)
            {
                Double val1 = Convert.ToDouble(dataGV_data.Rows[i].Cells[0].Value);
                Double val2 = Convert.ToDouble(dataGV_data.Rows[i].Cells[1].Value);
                if (!xUniqVals.Contains(val1))
                {
                    xUniqVals.Add(val1);
                }
                if (!yUniqVals.Contains(val2))
                {
                    yUniqVals.Add(val2);
                }
                xVals.Add(val1);
                yVals.Add(val2);
            }
            volumeTxtBx.Text     = (dataGV_data.RowCount - 1).ToString();
            xUniqCountTxtBx.Text = xUniqVals.Count.ToString();
            yUniqCountTxtBx.Text = yUniqVals.Count.ToString();
            xSchaleTxtBx.Text    = AnalysisClass.getScale(xUniqVals.Count);
            ySchaleTxtBx.Text    = AnalysisClass.getScale(yUniqVals.Count);

            Accord.Statistics.Distributions.Univariate.NormalDistribution normDist =
                Accord.Statistics.Distributions.Univariate.NormalDistribution.Standard;

            cl.CreateGraph(zg1, dataGV_data);

            if (!xSchaleTxtBx.Text.Equals("дихотомическая"))
            {
                Accord.Statistics.Testing.KolmogorovSmirnovTest kstX =
                    new Accord.Statistics.Testing.KolmogorovSmirnovTest(xVals.ToArray(), normDist);
                distrXTxtBx.Text = AnalysisClass.getDistributionScale(kstX.Significant);

                meanXTxtBx.Text   = MathNet.Numerics.Statistics.Statistics.Mean(xVals).ToString();
                stddevXTxtBx.Text = MathNet.Numerics.Statistics.Statistics.PopulationStandardDeviation(xVals).ToString();

                skewXTxtBx.Text = MathNet.Numerics.Statistics.Statistics.PopulationSkewness(xVals).ToString();
                kurtXTxtBx.Text = MathNet.Numerics.Statistics.Statistics.PopulationKurtosis(xVals).ToString();

                cl.CreateGraph3(zg3, dataGV_data);
            }

            if (!ySchaleTxtBx.Text.Equals("дихотомическая"))
            {
                Accord.Statistics.Testing.KolmogorovSmirnovTest kstY =
                    new Accord.Statistics.Testing.KolmogorovSmirnovTest(yVals.ToArray(), normDist);
                distrYTxtBx.Text = AnalysisClass.getDistributionScale(kstY.Significant);

                meanYTxtBx.Text   = MathNet.Numerics.Statistics.Statistics.Mean(yVals).ToString();
                stddevYTxtBx.Text = MathNet.Numerics.Statistics.Statistics.PopulationStandardDeviation(yVals).ToString();

                skewYTxtBx.Text = MathNet.Numerics.Statistics.Statistics.PopulationSkewness(yVals).ToString();
                kurtYTxtBx.Text = MathNet.Numerics.Statistics.Statistics.PopulationKurtosis(yVals).ToString();

                cl.CreateGraph2(zg2, dataGV_data);
            }

            coefficientsTxtBx.Text = AnalysisClass.getCorrelationCoefficients(
                xSchaleTxtBx.Text, distrXTxtBx.Text, ySchaleTxtBx.Text, distrYTxtBx.Text, dataGV_data.RowCount - 1);


            xVals.Clear();
            yVals.Clear();
            xUniqVals.Clear();
            yUniqVals.Clear();
        }
Пример #6
0
        private void button2_Click(object sender, EventArgs e)
        {
            SaveRegression saveRegression = new SaveRegression();

            if (!string.IsNullOrEmpty(richTextBox1.Text))
            {
                string        NumberOfVariable = "", NumberOfUqVariable = "", TypeOfScale = "", DistType = "", AGV = "", Slope = "", Mechanics = "", StandardDeviation = "";
                List <double> listtemp = new List <double>();
                int           temp     = 0;
                Accord.Statistics.Distributions.Univariate.NormalDistribution normDist =
                    Accord.Statistics.Distributions.Univariate.NormalDistribution.Standard;
                double[,] matr = new double[dataGridView1.RowCount, dataGridView1.ColumnCount];
                for (int j = 0; j < dataGridView1.ColumnCount; j++)
                {
                    for (int i = 0; i < dataGridView1.RowCount; i++)
                    {
                        matr[i, j] = Convert.ToDouble(dataGridView1.Rows[i].Cells[j].Value);
                        if (!listtemp.Contains(matr[i, j]))
                        {
                            temp++;
                        }
                        if (dataGridView1.Rows[i].Cells[j].Value != null)
                        {
                            listtemp.Add(matr[i, j]);
                        }
                    }

                    TypeOfScale        += AnalysisClass.getScale(temp) + "!";
                    NumberOfUqVariable += temp.ToString() + "!";
                    NumberOfVariable   += listtemp.Count().ToString() + "!";

                    if (AnalysisClass.getScale(temp) != "дихотомическая")
                    {
                        Accord.Statistics.Testing.KolmogorovSmirnovTest kstX =
                            new Accord.Statistics.Testing.KolmogorovSmirnovTest(listtemp.ToArray(), normDist);
                        DistType          += AnalysisClass.getDistributionScale(kstX.Significant) + "!";
                        AGV               += Math.Round(MathNet.Numerics.Statistics.Statistics.Mean(listtemp), 3).ToString() + "!";
                        StandardDeviation += Math.Round(MathNet.Numerics.Statistics.Statistics.PopulationStandardDeviation(listtemp), 3).ToString() + "!";
                        Mechanics         += Math.Round(MathNet.Numerics.Statistics.Statistics.PopulationSkewness(listtemp), 3).ToString() + "!";
                        Slope             += Math.Round(MathNet.Numerics.Statistics.Statistics.PopulationKurtosis(listtemp), 3).ToString() + "!";
                    }
                    else
                    {
                        DistType          += "Нет!";
                        AGV               += "Нет!";
                        StandardDeviation += "Нет!";
                        Mechanics         += "Нет!";
                        Slope             += "Нет!";
                    }
                    temp = 0;
                    listtemp.Clear();
                }

                DateRegression.TypeMethod         = richTextBox1.Text;
                DateRegression.NumberOfScale      = dataGridView1.ColumnCount;
                DateRegression.NumberOfVariable   = NumberOfVariable;
                DateRegression.NumberOfUqVariable = NumberOfUqVariable;
                DateRegression.TypeOfScale        = TypeOfScale;
                DateRegression.DistType           = DistType;
                DateRegression.StandardDeviation  = StandardDeviation;
                DateRegression.Mechanics          = Mechanics;
                DateRegression.AGV   = AGV;
                DateRegression.Slope = Slope;

                saveRegression.Show();
            }
            else
            {
                MessageBox.Show("Сначало нужно нажать кнопку 'Предложить метод исследования'");
            }
        }
Пример #7
0
        public static string getReggressionMethod(List <string> typeScale, string typeMethod, List <double> vs)
        {
            Accord.Statistics.Distributions.Univariate.NormalDistribution normDist =
                Accord.Statistics.Distributions.Univariate.NormalDistribution.Standard;

            Accord.Statistics.Testing.KolmogorovSmirnovTest kstX =
                new Accord.Statistics.Testing.KolmogorovSmirnovTest(vs.ToArray(), normDist);
            AnalysisClass.getDistributionScale(kstX.Significant);
            switch (typeMethod)
            {
            case "Простая линейная регрессия":
                if ((typeScale[0].Equals("ранговая") || typeScale[0].Equals("количественная")) && typeScale.Count == 2)
                {
                    return("Метод применим к данным");
                }
                else
                {
                    return("Метод не применим к данным");
                }

            case "Множественная линейная регрессия":
                if ((typeScale[0].Equals("ранговая") || typeScale[0].Equals("количественная")) && typeScale.Count > 2)
                {
                    return("Метод применим к данным");
                }
                else
                {
                    return("Метод не применим к данным");
                }

            case "Нелинейная регрессия":
                if ((typeScale[0].Equals("ранговая") || typeScale[0].Equals("количественная")) && typeScale.Count >= 2 && AnalysisClass.getDistributionScale(kstX.Significant) == "нормальное")
                {
                    return("Метод применим к данным");
                }
                else
                {
                    return("Метод не применим к данным");
                }

            case "Бинарная логистическая регрессия":
                if ((typeScale[0].Equals("дихотомическая")) && typeScale.Count > 2)
                {
                    return("Метод применим к данным");
                }
                else
                {
                    return("Метод не применим к данным");
                }

            case "Мультиномиальная логистическая регрессия":
                if (typeScale[0].Equals("ранговая") && typeScale.Count > 2 && AnalysisClass.getDistributionScale(kstX.Significant) == "нормальное")
                {
                    return("Метод применим к данным");
                }
                else
                {
                    return("Метод не применим к данным");
                }

            case "Порядковая регрессия":
                if (typeScale[0].Equals("ранговая") && typeScale.Count > 2 && AnalysisClass.getDistributionScale(kstX.Significant) == "нормальное")
                {
                    return("Метод применим к данным");
                }
                else
                {
                    return("Метод не применим к данным");
                }

            case "Пробит-анализ":
                if ((typeScale[0].Equals("дихотомическая")) && typeScale.Count > 2)
                {
                    return("Метод применим к данным");
                }
                else
                {
                    return("Метод не применим к данным");
                }

            default:
                return("Нет");
            }
        }