Exemplo n.º 1
0
        private TabPage CreateDixonSmirnovGrubbsCriteriaTab(ClimatData item, SQLiteConnection Connect)
        {
            TabPage      sub_tpage3 = new TabPage("Критерии Диксона и Смирнова-Граббса");
            DataGridView grid3      = new DataGridView();

            grid3.Anchor = (AnchorStyles.Bottom | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left);
            grid3.Dock   = DockStyle.Fill;

            DataTable table3 = new DataTable();

            {
                DataColumn IdColumn = new DataColumn("Id", Type.GetType("System.Int32"));
                IdColumn.Unique            = true;
                IdColumn.AllowDBNull       = false;
                IdColumn.AutoIncrement     = true;
                IdColumn.AutoIncrementSeed = 1;
                IdColumn.AutoIncrementStep = 1;

                DataColumn ExtremumColumn     = new DataColumn("Extremum", Type.GetType("System.String"));
                DataColumn CriteriaColumn     = new DataColumn("Criteria", Type.GetType("System.String"));
                DataColumn CalculatedColumn   = new DataColumn("Calculated", Type.GetType("System.Single"));
                DataColumn CriticalColumn     = new DataColumn("Critical", Type.GetType("System.Single"));
                DataColumn SignificanceColumn = new DataColumn("Significance", Type.GetType("System.Single"));
                DataColumn ResultColumn       = new DataColumn("Result", Type.GetType("System.String"));

                table3.Columns.Add(IdColumn);
                table3.Columns.Add(ExtremumColumn);
                table3.Columns.Add(CriteriaColumn);
                table3.Columns.Add(CalculatedColumn);
                table3.Columns.Add(CriticalColumn);
                table3.Columns.Add(SignificanceColumn);
                table3.Columns.Add(ResultColumn);
                table3.PrimaryKey = new DataColumn[] { table3.Columns["Id"] };
            }
            DixonGrubbsTable(table3, Connect, item, "Dixon1N");
            DixonGrubbsTable(table3, Connect, item, "Dixon2N");
            DixonGrubbsTable(table3, Connect, item, "Dixon3N");
            DixonGrubbsTable(table3, Connect, item, "Dixon4N");
            DixonGrubbsTable(table3, Connect, item, "Dixon5N");
            DixonGrubbsTable(table3, Connect, item, "Dixon11");
            DixonGrubbsTable(table3, Connect, item, "Dixon21");
            DixonGrubbsTable(table3, Connect, item, "Dixon31");
            DixonGrubbsTable(table3, Connect, item, "Dixon41");
            DixonGrubbsTable(table3, Connect, item, "Dixon51");
            DixonGrubbsTable(table3, Connect, item, "GrubbsN");
            DixonGrubbsTable(table3, Connect, item, "Grubbs1");

            grid3.DataBindingComplete += new DataGridViewBindingCompleteEventHandler(grid3_DataBindingComplete);
            grid3.DataSource           = table3;

            sub_tpage3.Controls.Add(grid3);

            return(sub_tpage3);
        }
Exemplo n.º 2
0
        private TabPage CreateSortedListTab(ClimatData item, int stat_id, string field_name)
        {
            TabPage      sub_tpage2 = new TabPage("Ранжированный ряд");
            DataGridView grid2      = new DataGridView();

            grid2.Anchor = (AnchorStyles.Bottom | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left);
            grid2.Dock   = DockStyle.Fill;

            DataTable table2 = new DataTable();
            {
                DataColumn IdColumn = new DataColumn("Id", Type.GetType("System.Int32"));
                IdColumn.Unique            = true;
                IdColumn.AllowDBNull       = false;
                IdColumn.AutoIncrement     = true;
                IdColumn.AutoIncrementSeed = 1;
                IdColumn.AutoIncrementStep = 1;

                DataColumn AvailabilityColumn = new DataColumn("Availability", Type.GetType("System.Single"));
                DataColumn ValueColumn        = new DataColumn("Value", Type.GetType("System.Single"));
                DataColumn YearColumn         = new DataColumn("Year", Type.GetType("System.Int32"));

                table2.Columns.Add(IdColumn);
                table2.Columns.Add(AvailabilityColumn);
                table2.Columns.Add(ValueColumn);
                table2.Columns.Add(YearColumn);
                table2.PrimaryKey = new DataColumn[] { table2.Columns["Id"] };
            }
            List <float> list2  = item.Y;
            List <int>   list2b = GetArrayDataYear(stat_id, field_name);

            list2.Reverse();
            list2b.Reverse();
            for (int i = 0; i < list2.Count; i++)
            {
                float availability = ((i + 1) / (list2.Count + 1)) * 100;
                table2.Rows.Add(new object[] { null, availability, list2[i], list2b[i] });
            }

            grid2.DataBindingComplete += new DataGridViewBindingCompleteEventHandler(grid2_DataBindingComplete);
            grid2.DataSource           = table2;

            sub_tpage2.Controls.Add(grid2);
            return(sub_tpage2);
        }
Exemplo n.º 3
0
        private TabPage CreateCalculationTab(ClimatData item)
        {
            TabPage     sub_tpage1 = new TabPage("Вычисления");
            RichTextBox rtb        = new RichTextBox();

            rtb.Anchor = (AnchorStyles.Bottom | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left);
            rtb.Dock   = DockStyle.Fill;

            rtb.Text = "Критерий Диксона:\n";

            rtb.Text += "D1n = " + item.DixonN[0] + "\n";
            rtb.Text += "D2n = " + item.DixonN[1] + "\n";
            rtb.Text += "D3n = " + item.DixonN[2] + "\n";
            rtb.Text += "D4n = " + item.DixonN[3] + "\n";
            rtb.Text += "D5n = " + item.DixonN[4] + "\n";
            rtb.Text += "D11 = " + item.Dixon1[0] + "\n";
            rtb.Text += "D21 = " + item.Dixon1[1] + "\n";
            rtb.Text += "D31 = " + item.Dixon1[2] + "\n";
            rtb.Text += "D41 = " + item.Dixon1[3] + "\n";
            rtb.Text += "D51 = " + item.Dixon1[4] + "\n\n";

            rtb.Text += "Среднее значение = " + item.Y.Average() + "\n";
            rtb.Text += "Дисперсия = " + item.Deviation + "\n\n";

            rtb.Text += "Критерий Смирнова-Граббса:\n";
            rtb.Text += "Gn = " + item.GrubbsN + "\n";
            rtb.Text += "G1 = " + item.Grubbs1 + "\n\n";
            rtb.Text += "Асимметрия = " + item.Asymmetry + "\n";
            rtb.Text += "Автокорреляция = " + item.Autocorrelation + "\n";
            rtb.Text += "t-распределение = " + item.TDistribution + "\n\n";

            rtb.Text += "Критерий Фишера = " + item.Fisher + "\n\n";

            rtb.Text += "Степень свободы n1 = " + item.FDistribution1 + "\n";
            rtb.Text += "Степень свободы n2 = " + item.FDistribution2 + "\n\n";

            rtb.Text += "Критерий Стьюдента = " + item.Student + "\n\n";

            sub_tpage1.Controls.Add(rtb);

            return(sub_tpage1);
        }
Exemplo n.º 4
0
        private void DixonGrubbsTable(DataTable table, SQLiteConnection Connect, ClimatData item, string table_name)
        {
            float         significance = 5.0f;
            string        result       = "";
            SQLiteCommand Command      = new SQLiteCommand();

            Command.Connection  = Connect;
            Command.CommandText = @"SELECT CriticalValue FROM " + table_name + @"
                                    ORDER BY ABS(Asymmetry - @asymmetry),
                                                ABS(SignificanceLevel - @significance),
		                                        ABS(Autocorrelation - @autocorrelation),
		                                        ABS(SampleSize - @samplesize)
                                    LIMIT 1";
            Command.Parameters.AddWithValue("@asymmetry", item.Asymmetry);
            Command.Parameters.AddWithValue("@significance", 5.0);
            Command.Parameters.AddWithValue("@autocorrelation", item.Autocorrelation);
            Command.Parameters.AddWithValue("@samplesize", item.Y.Count);
            SQLiteDataReader sqlReader = Command.ExecuteReader();
            float            value = 0f, critval = 0f;

            switch (table_name)
            {
            case "Dixon11": value = item.Dixon1[0]; break;

            case "Dixon1N": value = item.DixonN[0]; break;

            case "Dixon21": value = item.Dixon1[1]; break;

            case "Dixon2N": value = item.DixonN[1]; break;

            case "Dixon31": value = item.Dixon1[2]; break;

            case "Dixon3N": value = item.DixonN[2]; break;

            case "Dixon41": value = item.Dixon1[3]; break;

            case "Dixon4N": value = item.DixonN[3]; break;

            case "Dixon51": value = item.Dixon1[4]; break;

            case "Dixon5N": value = item.DixonN[4]; break;

            case "Grubbs1": value = item.Grubbs1; break;

            case "GrubbsN": value = item.GrubbsN; break;

            default: break;
            }

            if (sqlReader.Read())
            {
                critval = sqlReader.GetFloat(sqlReader.GetOrdinal("CriticalValue"));
            }
            if (critval > value)
            {
                result = "Однороден";
            }
            else
            {
                result = "Неоднороден";
            }

            string maxmin = "";
            string name = "";

            if (table_name[table_name.Length - 1] == 'N')
            {
                maxmin = "max";
            }
            else if (table_name[table_name.Length - 1] == '1')
            {
                maxmin = "min";
            }
            if (table_name.Contains("Dixon"))
            {
                name = "Диксон " + table_name[table_name.Length - 2];
            }
            else if (table_name.Contains("Grubbs"))
            {
                name = "Смирнов-Граббс";
            }

            table.Rows.Add(new object[] { null, maxmin, name, value, critval, significance, result });
        }
Exemplo n.º 5
0
        public Form2()
        {
            InitializeComponent();
            path = Form1.final_path;
            List <ClimatData> data = new List <ClimatData>();

            using (SQLiteConnection Connect = new SQLiteConnection(@"Data Source=ClimatTables.db"))
            {
                Connect.Open();
                foreach (DataRow station in Form1.statListTable.Rows)
                {
                    int        stat_id       = station.Field <int>(Form1.statListTable.Columns[0]);
                    string     stat_name     = station.Field <string>(Form1.statListTable.Columns[1]);
                    TabPage    stat_tpage    = new TabPage(stat_name);
                    TabControl stat_tcontrol = new TabControl();
                    stat_tcontrol.Anchor = (AnchorStyles.Bottom | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left);
                    stat_tcontrol.Dock   = DockStyle.Fill;
                    stat_tpage.Controls.Add(stat_tcontrol);

                    foreach (DataRow field in Form1.fldTable.Rows)
                    {
                        int    field_id       = field.Field <int>(Form1.fldTable.Columns[0]);
                        string field_name     = field.Field <string>(Form1.fldTable.Columns[3]);
                        bool   field_is_value = field.Field <string>(Form1.fldTable.Columns[2]).Contains(",");

                        if (!field_is_value)
                        {
                            continue;
                        }

                        ClimatData item = new ClimatData(GetArrayData(stat_id, field_name));

                        item = OutlierTest.Dixon(item);
                        item = OutlierTest.Deviation(item);
                        item = OutlierTest.Grubbs(item);
                        item = OutlierTest.Asymmetry(item);
                        item = OutlierTest.Autocorrelation(item);
                        item = OutlierTest.TDistribution(item);
                        item = OutlierTest.Fisher(item);
                        item = OutlierTest.FDistribution(item);
                        item = OutlierTest.Student(item);

                        data.Add(item);

                        TabPage    field_tpage    = new TabPage(field_name);
                        TabControl field_tcontrol = new TabControl();
                        field_tcontrol.Anchor = (AnchorStyles.Bottom | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left);
                        field_tcontrol.Dock   = DockStyle.Fill;
                        field_tpage.Controls.Add(field_tcontrol);

                        // Вычисления - не нужно
                        //field_tcontrol.TabPages.Add(CreateCalculationTab(item));

                        // Ранжированный ряд
                        field_tcontrol.TabPages.Add(CreateSortedListTab(item, stat_id, field_name));

                        // Критерии Диксона и Смирнова-Граббса
                        field_tcontrol.TabPages.Add(CreateDixonSmirnovGrubbsCriteriaTab(item, Connect));

                        // Критерии Фишера и Стьюдента
                        field_tcontrol.TabPages.Add(CreateFisherStudentCriteriaTab(item, Connect));

                        stat_tcontrol.TabPages.Add(field_tpage);
                    }

                    //TabPage sub_tpage5 = new TabPage("Критерии Фишера и Стьюдента");
                    //DataGridView grid5 = new DataGridView();
                    //grid5.Anchor = (AnchorStyles.Bottom | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left);
                    //grid5.Dock = DockStyle.Fill;

                    //DataTable table5 = new DataTable();
                    //{
                    //    {
                    //        DataColumn IdColumn = new DataColumn("Id", Type.GetType("System.Int32"));
                    //        IdColumn.Unique = true;
                    //        IdColumn.AllowDBNull = false;
                    //        IdColumn.AutoIncrement = true;
                    //        IdColumn.AutoIncrementSeed = 1;
                    //        IdColumn.AutoIncrementStep = 1;

                    //        DataColumn CriteriaColumn = new DataColumn("Criteria", Type.GetType("System.String"));
                    //        DataColumn CalculatedColumn = new DataColumn("Calculated", Type.GetType("System.Single"));
                    //        DataColumn CriticalColumn = new DataColumn("Critical", Type.GetType("System.Single"));
                    //        DataColumn SignificanceColumn = new DataColumn("Significance", Type.GetType("System.Single"));
                    //        DataColumn ResultColumn = new DataColumn("Result", Type.GetType("System.String"));

                    //        table5.Columns.Add(IdColumn);
                    //        table5.Columns.Add(CriteriaColumn);
                    //        table5.Columns.Add(CalculatedColumn);
                    //        table5.Columns.Add(CriticalColumn);
                    //        table5.Columns.Add(SignificanceColumn);
                    //        table5.Columns.Add(ResultColumn);
                    //        table5.PrimaryKey = new DataColumn[] { table5.Columns["Id"] };
                    //    }
                    //}

                    //{

                    //}

                    //grid5.DataBindingComplete += new DataGridViewBindingCompleteEventHandler(grid4_DataBindingComplete);
                    //grid5.DataSource = table5;

                    //sub_tpage5.Controls.Add(grid5);
                    //stat_tcontrol.TabPages.Add(sub_tpage5);

                    tabControl1.TabPages.Add(stat_tpage);
                }
            }
        }
Exemplo n.º 6
0
        private TabPage CreateFisherStudentCriteriaTab(ClimatData item, SQLiteConnection Connect)
        {
            TabPage      sub_tpage4 = new TabPage("Критерии Фишера и Стьюдента");
            DataGridView grid4      = new DataGridView();

            grid4.Anchor = (AnchorStyles.Bottom | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left);
            grid4.Dock   = DockStyle.Fill;

            DataTable table4 = new DataTable();

            {
                {
                    DataColumn IdColumn = new DataColumn("Id", Type.GetType("System.Int32"));
                    IdColumn.Unique            = true;
                    IdColumn.AllowDBNull       = false;
                    IdColumn.AutoIncrement     = true;
                    IdColumn.AutoIncrementSeed = 1;
                    IdColumn.AutoIncrementStep = 1;

                    DataColumn CriteriaColumn     = new DataColumn("Criteria", Type.GetType("System.String"));
                    DataColumn CalculatedColumn   = new DataColumn("Calculated", Type.GetType("System.Single"));
                    DataColumn CriticalColumn     = new DataColumn("Critical", Type.GetType("System.Single"));
                    DataColumn SignificanceColumn = new DataColumn("Significance", Type.GetType("System.Single"));
                    DataColumn ResultColumn       = new DataColumn("Result", Type.GetType("System.String"));

                    table4.Columns.Add(IdColumn);
                    table4.Columns.Add(CriteriaColumn);
                    table4.Columns.Add(CalculatedColumn);
                    table4.Columns.Add(CriticalColumn);
                    table4.Columns.Add(SignificanceColumn);
                    table4.Columns.Add(ResultColumn);
                    table4.PrimaryKey = new DataColumn[] { table4.Columns["Id"] };
                }
            }

            {
                float         significance = 5.0f;
                string        result       = "";
                SQLiteCommand Command      = new SQLiteCommand();
                Command.Connection  = Connect;
                Command.CommandText = @"SELECT CriticalValue FROM Fisher1
                                                    ORDER BY ABS(SampleSize - @samplesize),
                                                             ABS(SignificanceLevel - @significance),
		                                                     ABS(Correlation - @correlation),
		                                                     ABS(Autocorrelation - @autocorrelation)
                                                    LIMIT 1";
                Command.Parameters.AddWithValue("@samplesize", item.Y1.Count);
                Command.Parameters.AddWithValue("@significance", 5.0);
                Command.Parameters.AddWithValue("@correlation", 0.0);
                Command.Parameters.AddWithValue("@autocorrelation", item.Autocorrelation);
                SQLiteDataReader sqlReader = Command.ExecuteReader();
                float            critval   = 0f;

                if (sqlReader.Read())
                {
                    critval = sqlReader.GetFloat(sqlReader.GetOrdinal("CriticalValue"));
                }
                if (critval > item.Fisher)
                {
                    result = "Однороден";
                }
                else
                {
                    result = "Неоднороден";
                }

                table4.Rows.Add(new object[] { null, "Критерий Фишера", item.Fisher, critval, significance, result });
            }

            {
                float         significance = 5.0f;
                string        result       = "";
                SQLiteCommand Command      = new SQLiteCommand();
                Command.Connection  = Connect;
                Command.CommandText = @"SELECT CriticalValue FROM Student1
                                                    ORDER BY ABS(SampleSize - @samplesize),
                                                             ABS(SignificanceLevel - @significance),
		                                                     ABS(Correlation - @correlation),
		                                                     ABS(Autocorrelation - @autocorrelation)
                                                    LIMIT 1";
                Command.Parameters.AddWithValue("@samplesize", item.Y1.Count);
                Command.Parameters.AddWithValue("@significance", 5.0);
                Command.Parameters.AddWithValue("@correlation", 0.0);
                Command.Parameters.AddWithValue("@autocorrelation", item.Autocorrelation);
                SQLiteDataReader sqlReader = Command.ExecuteReader();
                float            critval   = 0f;

                if (sqlReader.Read())
                {
                    critval = sqlReader.GetFloat(sqlReader.GetOrdinal("CriticalValue"));
                }
                if (critval > item.Student)
                {
                    result = "Однороден";
                }
                else
                {
                    result = "Неоднороден";
                }

                table4.Rows.Add(new object[] { null, "Критерий Стьюдента", item.Student, critval, significance, result });
            }

            grid4.DataBindingComplete += new DataGridViewBindingCompleteEventHandler(grid4_DataBindingComplete);
            grid4.DataSource           = table4;

            sub_tpage4.Controls.Add(grid4);
            return(sub_tpage4);
        }