Beispiel #1
0
        private void BtnCalc_OnClick(object sender, RoutedEventArgs e)
        {
            int n = 629, m = 10;
            var matrix       = ReadDataMatrix(@"D:\Универ\3 курс\2 семестр\Тер вер и мат стат\movie_metadata_1.csv");
            var transpMatrix = MatrixFunction.TransposeMatrix(matrix);
            Dictionary <double, double> laplasMatrix = ReadLaplasMatrix("2.txt");

            tbDescript.Text = "";
            for (int k = 0; k < m; ++k)
            {
                PearsonConsentCriterion    pcc = new PearsonConsentCriterion(transpMatrix[k].Take(n).ToArray(), laplasMatrix);
                KolmogorovConsentCriterion kcc = new KolmogorovConsentCriterion(transpMatrix[k]);
                DescriptiveStatistics      ds  = new DescriptiveStatistics(transpMatrix[k]);
                tbDescript.Text += String.Format("Параметр: {0}\n", k + 1);
                tbDescript.Text += String.Format("Среднее арифметическое = {0}\n", ds.ArithmeticalMean);
                tbDescript.Text += String.Format("Мода = {0}\n", ds.Mode);
                tbDescript.Text += String.Format("Медиана = {0}\n", ds.Median);
                tbDescript.Text += String.Format("Дисперсия = {0}\n", ds.Dispersion);
                tbDescript.Text += String.Format("Асимметрия = {0}\n", ds.Assimmetry);
                tbDescript.Text += String.Format("Эксцесс = {0}\n", ds.Excess);
                tbDescript.Text += String.Format("Стандартное отклонение = {0}\n", ds.StandardDeviation);
                tbDescript.Text += String.Format("Коэффициент вариации = {0}\n", ds.VariationCoefficient);
                tbDescript.Text += String.Format("Размах вариации = {0}\n", ds.VariationRange);
                tbDescript.Text += String.Format("Среднее значение x: " + pcc.AverageValueX);
                tbDescript.Text += String.Format("Среднее квадратичное отклонение: " + pcc.MeanSquareDeviation);
                tbDescript.Text += String.Format("Критерий Пирсона: " + pcc.PearsonCriterionValue);
                tbDescript.Text += String.Format("Табличный критерий Пирсона = " + 63.6567);
                tbDescript.Text += String.Format("Критерий Колмогорова = " + kcc.KolmogorovCriterionValue);
                tbDescript.Text += String.Format("Табличный критерий Колмогорова = 1,950\n\n");
            }

            tbCorrelations.Text = "";
            CorrelationsAnalysis correlationsAnalyses = new CorrelationsAnalysis(transpMatrix, m - 1);

            tbCorrelations.Text += "Матрица корреляции\n";
            foreach (double[] correlationCoef in correlationsAnalyses.PairCorrelationsMatrix)
            {
                for (int j = 0; j < correlationCoef.Length; j++)
                {
                    tbCorrelations.Text += String.Format("{0}    ", Math.Round(correlationCoef[j], 5));
                }
                tbCorrelations.Text += '\n';
            }

            tbCorrelations.Text += "Коэффициенты значимости для матрицы парных корреляций: \n";
            foreach (double[] t in correlationsAnalyses.MatrixSignificanceFactors)
            {
                for (int j = 0; j < t.Length; j++)
                {
                    tbCorrelations.Text += String.Format("{0}         ", Math.Round(t[j], 5));
                }
                tbCorrelations.Text += '\n';
            }

            tbCorrelations.Text += "Коэффициенты значимости:\n";
            foreach (double t in correlationsAnalyses.ParametersSignificanceFactors)
            {
                tbCorrelations.Text += t;
            }
            tbCorrelations.Text += "\n";

            var multipleCoefficientY      = correlationsAnalyses.SelectiveMultipleCoefficient;
            var determinationCoefficientY = correlationsAnalyses.DeterminationCoefficient;

            tbCorrelations.Text += String.Format("Выборочный множественный коэффициент Y: " + multipleCoefficientY);
            tbCorrelations.Text += String.Format("Коэффициент детерминации: " + determinationCoefficientY);
            if (determinationCoefficientY > 0.75)
            {
                tbCorrelations.Text += String.Format("Модель адекватна");
            }

            tbCorrelations.Text += '\n';
            tbCorrelations.Text += String.Format("Матрица частной корреляции");
            foreach (double[] t in correlationsAnalyses.PartialCorrelationsMatrix)
            {
                for (int j = 0; j < correlationsAnalyses.PartialCorrelationsMatrix.Length; j++)
                {
                    tbCorrelations.Text += String.Format("{0,6}  ", Math.Round(t[j], 4));
                }
                tbCorrelations.Text += "\n";
            }
            tbCorrelations.Text += "\n";

            RegressionAnalysis ra = new RegressionAnalysis(matrix, m - 1);

            tbRegressions.Text = "Коэффициенты регрессии:\n";
            for (int i = 0; i < ra.RegressionCoefficients.Length; i++)
            {
                if (i == 0)
                {
                    tbRegressions.Text += String.Format("a = {0}\n", ra.RegressionCoefficients[i]);
                }
                else
                {
                    tbRegressions.Text += String.Format("b{0} = {1}\n", i, ra.RegressionCoefficients[i]);
                }
            }

            tbRegressions.Text += String.Format("Значимость коэффициентов регрессии:");
            for (int i = 0; i < m; i++)
            {
                tbRegressions.Text += String.Format("b{0} = {1}", (i + 1), ra.RegressionCoefficientsSignificance[i]);
            }

            tbRegressions.Text += String.Format("Доверительные интервалы коэффициентов регрессии:");
            for (int i = 0; i < m; i++)
            {
                tbRegressions.Text += String.Format("{0} <= b{1} <= {2}", ra.ConfidenceIntervalsOfCoefficients[i].Item1, (i + 1), ra.ConfidenceIntervalsOfCoefficients[i].Item2);
            }

            tbRegressions.Text += String.Format("Коэффициент значимости уравнения регрессии:");
            tbRegressions.Text += String.Format(ra.RegressionEquationSignificance.ToString());

            tbRegressions.Text += String.Format("\nКоэффициенты эластичности");
            double[] elast = ra.ElasticityCoefficients;
            for (int u = 0; u < m; u++)
            {
                tbRegressions.Text += String.Format("x{0} = {1}", (u + 1), elast[u]);
            }

            Forecast f = new Forecast(matrix, m - 1);

            tbForecast.Text  = "Прогнозирование\n";
            tbForecast.Text += string.Format(f.Value[0] + " < y < " + f.Value[1]);
        }