示例#1
0
        ///////////////////////////////////////////////////////////////////////////////////////
        /// ДЕЙСТВИЯ С ТАБЛИЦОЙ
        ///////////////////////////////////////////////////////////////////////////////////////

        //Расчет числовых характеристик  и вывод
        private void menuCalc_Click(object sender, EventArgs e)
        {
            cor_calc    = new CorrelationCalc(cor_table);
            calc_exists = true;
            setup_gui();

            txtX.Text  = cor_calc.X.ToString("N4");
            txtY.Text  = cor_calc.Y.ToString("N4");
            txtSx.Text = cor_calc.Sx.ToString("N4");
            txtSy.Text = cor_calc.Sy.ToString("N4");
            txtR.Text  = cor_calc.R.ToString("N4");
        }
示例#2
0
        private void draw_lines(CorrelationCalc calc, double b0, double b1)
        {
            //double b0 = calc.Y - calc.B1 * calc.X;
            double x_left  = calc.Table.XHeaders.First().Left;
            double x_right = calc.Table.XHeaders.Last().Right;
            double y_left  = b0 + b1 * x_left;
            double y_right = b0 + b1 * x_right;

            var pane = graph.GraphPane;

            pane.AddCurve("", new double[] { x_left, x_right }, new double[] { y_left, y_right }, Color.Red);
            pane.AxisChange();
            graph.Invalidate();
        }
示例#3
0
        public DiagramForm(List <Regression.Utils.PointD> data, CorrelationCalc calc)
        {
            InitializeComponent();
            setup_graph();

            var    pane = graph.GraphPane;              //Поверхность рисования
            var    table = calc.Table;                  //Корреляционная таблица
            double x_1, x_2, y_1, y_2;                  //Координаты концов линий регрессии
            var    points = new PointPairList();

            //Построение точек
            foreach (var x in data)
            {
                points.Add(x.X, x.Y);
            }

            //Добавляем точки на график и убираем линию.
            var curve = pane.AddCurve("", points, Color.Green, SymbolType.Circle);

            curve.Line.IsVisible   = false;
            curve.Symbol.Fill.Type = FillType.Solid;
            curve.Symbol.Size      = 5;

            //Построение графиков
            //y = B0  + B1 *x
            x_1 = calc.Table.XHeaders.First().Left;
            x_2 = calc.Table.XHeaders.Last().Right;
            y_1 = calc.B0 + calc.B1 * x_1;
            y_2 = calc.B0 + calc.B1 * x_2;

            curve = pane.AddCurve(String.Format("y = {0:N2} + {1:N2}x", calc.B0, calc.B1), new double[] { x_1, x_2 }, new double[] { y_1, y_2 }, Color.Red, SymbolType.None);
            curve.Line.IsAntiAlias = true;

            //x = B0' + B1'*y
            y_1 = calc.Table.YHeaders.First().Left;
            y_2 = calc.Table.YHeaders.Last().Right;
            x_1 = calc.B0_ + calc.B1_ * y_1;
            x_2 = calc.B0_ + calc.B1_ * y_2;

            curve = pane.AddCurve(String.Format("x = {0:N2} + {1:N2}y", calc.B0_, calc.B1_), new double[] { x_1, x_2 }, new double[] { y_1, y_2 }, Color.Blue, SymbolType.None);
            curve.Line.IsAntiAlias = true;


            //Построение точки пересечения
            pane.AddCurve("", new double[] { calc.X }, new double[] { calc.Y }, Color.Blue, SymbolType.Circle);

            pane.AxisChange();
            graph.Invalidate();
        }
示例#4
0
        ///////////////////////////////////////////////////////////////////////////////////////
        /// СОЗДАНИЕ, ОТКРЫТИЕ, ВВОД КОРРЕЛЯЦИОННОЙ ТАБЛИЦЫ
        ///////////////////////////////////////////////////////////////////////////////////////


        //Очищает все таблицы и прочее
        private void reset_all()
        {
            gridCorrelationInput.Rows.Clear();
            gridCorrelationInput.Columns.Clear();

            data                = new BindingList <PointD>();
            data.AllowEdit      = false;;
            data.AllowNew       = false;
            data.AllowRemove    = false;
            gridData.DataSource = data;

            cor_table = null;
            cor_calc  = null;

            txtX.Text  = "";
            txtY.Text  = "";
            txtSx.Text = "";
            txtSy.Text = "";
            txtR.Text  = "";

            gui_flags_set(false);
            setup_gui();
        }
示例#5
0
        public AdditionalValuesForm(CorrelationCalc calc)
        {
            InitializeComponent();
            htmlPanel = new TheArtOfDev.HtmlRenderer.WinForms.HtmlPanel();

            var          table = calc.Table;
            var          gen   = new HTMLTableGenerator();
            HTMLTableRow row;

            //Создание шапки
            row = gen.AddRow();
            row.AddCell("Границы и середины интервалов для y", 1, 4);
            row.AddCell("Vj", 1, 3);
            row.AddCell("Границы и середины интервалов для x", table.Width, 1);
            row.AddCell("Nj", 1, 4);
            row.AddCell("NjVj", 1, 4);
            row.AddCell("NjVj^2", 1, 4);

            row = gen.AddRow();
            foreach (var x in table.XHeaders)
            {
                row.AddCell(range_to_string(x), "#B2DFDB");
            }

            row = gen.AddRow();
            //row.AddCell("Ui", table.Width, 1);

            row = gen.AddRow();
            row.AddCell("Ui ->");
            foreach (var x in calc.Ui)
            {
                row.AddCell(x.ToString("N2"));
            }


            //Создание таблицы
            for (int y = 0; y < table.Height; y++)
            {
                row = gen.AddRow();
                row.AddCell(range_to_string(table.YHeaders[y]), "#B2DFDB");
                row.AddCell(calc.Vj[y].ToString("N2"));

                //Значения
                for (int x = 0; x < table.Width; x++)
                {
                    row.AddCell(table[x, y].ToString("N2"), "#B2DFDB");
                }

                row.AddCell(calc.Nj[y].ToString("N2"));
                row.AddCell((calc.Nj[y] * calc.Vj[y]).ToString("N2"));
                row.AddCell((calc.Nj[y] * calc.Vj[y] * calc.Vj[y]).ToString("N2"));
            }

            //Нижние строки
            //Ni
            row = gen.AddRow();
            row.AddCell("Ni", 2, 1);
            foreach (var x in calc.Ni)
            {
                row.AddCell(x.ToString("N2"));
            }

            row.AddCell("Сумма: " + calc.N.ToString("N2"));
            row.AddCell("Сумма: " + calc.NjVj.ToString("N2"));
            row.AddCell("Сумма: " + calc.NjVj2.ToString("N2"));

            //NiUi
            row = gen.AddRow();
            row.AddCell("NiUi", 2, 1);
            for (int i = 0; i < table.Width; i++)
            {
                row.AddCell((calc.Ni[i] * calc.Ui[i]).ToString("N2"));
            }

            row.AddCell("Сумма: " + calc.NiUi.ToString("N2"));

            //NiUi2
            row = gen.AddRow();
            row.AddCell("NiUi^2", 2, 1);
            for (int i = 0; i < table.Width; i++)
            {
                row.AddCell((calc.Ni[i] * calc.Ui[i] * calc.Ui[i]).ToString("N2"));
            }

            row.AddCell("Сумма: " + calc.NiUi2.ToString("N2"));

            /*var str = gen.GetHTML();
             * using (var sw = new StreamWriter("D:\\index.html"))
             * {
             *      sw.WriteLine(str);
             * }*/

            htmlPanel.Text = gen.GetHTML();
            htmlPanel.Dock = DockStyle.Fill;
            Controls.Add(htmlPanel);
            htmlPanel.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;
            htmlPanel.Width  = this.Width;
            htmlPanel.Height = this.ClientSize.Height - groupBox1.Height - 10;

            txtQu.Text  = calc.Qu.ToString("N4");
            txtQv.Text  = calc.Qv.ToString("N4");
            txtQuv.Text = calc.Quv.ToString("N4");
        }