Пример #1
0
        public TemperatureMap(NNData data1)
        {
            this.AutoScroll = true;
            InitializeComponent();
            pictureBox1.Height = 32 * data1.Length;
            pictureBox1.Width  = 64 * data1.Num;
            NNData data = Check(data1);


            Bitmap   OutputImage = new Bitmap(64 * data.Num, 32 * data.Length, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            Bitmap   Temp        = new Bitmap(64, 32, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            Graphics G           = Graphics.FromImage(OutputImage);
            Graphics TempG       = Graphics.FromImage(Temp);
            Pen      BlackPen    = new Pen(Color.Black, 0.3f);
            int      TempRead    = 0;

            for (int i = 0, j; i < data.Num; i++)
            {
                double[] arr = NNData.PartArr(data.ARR, data.Length, i);
                for (j = 0; j < data.Length; j++)
                {
                    TempRead = (255 * data.ARR[j, i] / arr.Max() > 255) ? 255 : (int)(Math.Round(255 * data.ARR[j, i] / arr.Max()));
                    TempG.Clear(Color.FromArgb(155, 0, TempRead, TempRead));
                    TempG.DrawRectangle(BlackPen, 0, 0, Temp.Width, Temp.Height);
                    G.DrawImage(Temp, i * 64, j * 32);
                }
            }
            pictureBox1.Image = OutputImage;
        }
Пример #2
0
        public ChastkovyyZnachushchist(NNData data)
        {
            InitializeComponent();

            for (int i = 0; i < data.Num; i++)
            {
                dataGridView1.Columns.Add(i.ToString(), i.ToString());
                dataGridView1.Rows.Add();
            }
            for (int i = 0; i < data.Num; i++)
            {
                for (int j = 0; j < data.Num; j++)
                {
                    if (data.Znachushchist[i, j] != "")
                    {
                        double stat = statistic(Convert.ToDouble(data.Znachushchist[i, j]), data.Length, data.kor_num);
                        if (Math.Abs(stat) <= Quantil.StudentQuantil1(data.Length - data.kor_num - 2))
                        {
                            dataGridView1.Rows[i].Cells[j].Value = stat.ToString("N5") + ", True";
                        }
                        else
                        {
                            dataGridView1.Rows[i].Cells[j].Value = stat.ToString("N5") + ", False";
                        }
                    }
                }
            }
        }
Пример #3
0
        public static NNData Check(NNData data)
        {
            double[] min_arr = new double[data.Num];
            for (int i = 0; i < data.Num; i++)
            {
                double[] arr = NNData.PartArr(data.ARR, data.Length, i);
                min_arr[i] = arr.Min();
            }
            double abs_min = min_arr.Min();

            if (abs_min >= 0)
            {
                return(data);
            }
            abs_min           = Math.Abs(abs_min);
            double[,] new_arr = new double[data.Length, data.Num];
            for (int i = 0; i < data.Num; i++)
            {
                for (int j = 0; j < data.Length; j++)
                {
                    new_arr[j, i] = data.ARR[j, i] + abs_min + 1;
                }
            }
            return(new NNData(Tuple.Create(new_arr, data.Num, data.Length, data.file_name)));
        }
Пример #4
0
        public static double VStatistic(NNData d1, NNData d2)
        {
            Matrix m0 = Matrix.Create.New(s0(d1, d2));
            Matrix m1 = Matrix.Create.New(s1(d1, d2));

            return(-1d * (d1.Length + d2.Length - 2 - d1.Num / 2d) * Math.Log(m1.Determinant() / m0.Determinant()));
        }
Пример #5
0
        private void charts_filling(ref Chart[,] charts, NNData data, ref int pointer)
        {
            double[] arr_max = data.arr_max;
            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    if (pointer == data.Length)
                    {
                        return;
                    }
                    chart[i, j].Series.Add(pointer.ToString());
                    chart[i, j].Series[pointer.ToString()].ChartArea   = "ChartArea1";
                    chart[i, j].Series[pointer.ToString()].BorderWidth = 1;
                    chart[i, j].Series[pointer.ToString()].ChartType   = SeriesChartType.Radar;
                    chart[i, j].ChartAreas[0].AxisX.Title = (pointer + 1).ToString();

                    for (int k = 0; k < data.Num; k++)
                    {
                        chart[i, j].Series[pointer.ToString()].Points.AddXY(k, data.ARR[pointer, k] / arr_max[k]);
                    }
                    pointer++;
                }
            }
        }
Пример #6
0
        public static double MnozhynnKorelation(NNData data, int index)
        {
            double[,] new_matrix = part_matrix(data.KorelationMatrix, index);
            Matrix main_matrix   = Matrix.Create.New(data.KorelationMatrix);
            Matrix little_matrix = Matrix.Create.New(new_matrix);

            return(Math.Sqrt(1 - main_matrix.Determinant() / little_matrix.Determinant()));
        }
Пример #7
0
        private static double[,] s0(NNData d1, NNData d2)
        {
            double[,] ret = new double[d1.Num, d2.Num];
            for (int i = 0; i < ret.GetLength(0); i++)
            {
                for (int j = 0; j < ret.GetLength(1); j++)
                {
                    ret[i, j] = s0_ij(NNData.PartArr(d1.ARR, d1.Length, i), NNData.PartArr(d1.ARR, d1.Length, j), NNData.PartArr(d2.ARR, d2.Length, i), NNData.PartArr(d2.ARR, d2.Length, j));
                }
            }

            return(ret);
        }
Пример #8
0
        private static double sd(NNData d)
        {
            double[] m = d.SerAr();

            List <double> tmp = new List <double>();

            for (int i = 0; i < d.Num; i++)
            {
                tmp.AddRange(NNData.PartArr(d.ARR, d.Length, i).Select(e => e - m[i]));
            }

            Vector v = new Vector(tmp.ToArray());

            return(v * v / (d.Length - 1d));
        }
Пример #9
0
        public Radar(NNData data)
        {
            InitializeComponent();
            data      = TemperatureMap.Check(data);
            this.data = data;

            tableLayoutPanel1.Controls.Clear();
            tableLayoutPanel1.ColumnStyles.Clear();
            tableLayoutPanel1.RowStyles.Clear();
            this.WindowState = FormWindowState.Maximized;
            tableLayoutPanel1.ColumnCount = 5;
            tableLayoutPanel1.RowCount    = 5;
            for (int i = 0; i < 5; i++)
            {
                tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 200f / data.Num));
                tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Percent, 200f / data.Num));
            }

            chart = new Chart[5, 5];

            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    Chart     chart1     = new Chart();
                    ChartArea chartArea1 = new ChartArea();
                    chartArea1.Name = "ChartArea1";
                    chart1.ChartAreas.Add(chartArea1);
                    ((System.ComponentModel.ISupportInitialize)(chart1)).BeginInit();
                    chart1.BorderlineColor     = System.Drawing.Color.Black;
                    chart1.BorderlineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Solid;
                    chart1.Size = new System.Drawing.Size(400, 400);
                    chart[i, j] = chart1;
                    tableLayoutPanel1.Controls.Add(chart[i, j], i, j);
                    chart1.ChartAreas[0].AxisY.Maximum = 1;
                }
            }

            charts_filling(ref chart, data, ref num);
        }
Пример #10
0
        public Sitka(NNData data)
        {
            InitializeComponent();
            chart1.Series.Clear();
            data = TemperatureMap.Check(data);
            chart1.ChartAreas[0].AxisX.Maximum = data.Num - 1;
            chart1.ChartAreas[0].AxisX.Minimum = 0;
            chart1.ChartAreas[0].AxisY.Maximum = 1;
            chart1.ChartAreas[0].AxisY.Minimum = 0;
            double[] arr_max = data.arr_max;

            for (int i = 0; i < data.Length; i++)
            {
                chart1.Series.Add(i.ToString());
                chart1.Series[i.ToString()].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
                chart1.Series[i.ToString()].Color     = Color.Blue;
                for (int j = 0; j < data.Num; j++)
                {
                    chart1.Series[i.ToString()].Points.AddXY(j, data.ARR[i, j] / arr_max[j]);
                }
            }
        }
Пример #11
0
        public MultiCharting(NNData data)
        {
            InitializeComponent();
            tableLayoutPanel1.Controls.Clear();
            tableLayoutPanel1.ColumnStyles.Clear();
            tableLayoutPanel1.RowStyles.Clear();

            this.data = data;
            tableLayoutPanel1.ColumnCount = data.Num;
            tableLayoutPanel1.RowCount    = data.Num;
            for (int i = 0; i < data.Num; i++)
            {
                tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100f / data.Num));
                tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Percent, 100f / data.Num));
            }

            Chart[,] CHARTS = new Chart[data.Num, data.Num];
            int num = 0;

            for (int g = 0; g < data.Num; g++)
            {
                for (int k = 0; k < data.Num; k++)
                {
                    double[] part_arr = NNData.PartArr(data.ARR, data.Length, k);
                    double   min      = part_arr.Min();
                    int      numclass = korelation.num_class(part_arr);
                    double   step     = (part_arr.Max() - min) / numclass;

                    Chart     chart1     = new Chart();
                    ChartArea chartArea1 = new ChartArea();
                    chartArea1.Name = "ChartArea1";
                    chart1.ChartAreas.Add(chartArea1);
                    ((System.ComponentModel.ISupportInitialize)(chart1)).BeginInit();
                    chart1.BorderlineColor     = System.Drawing.Color.Black;
                    chart1.BorderlineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Solid;
                    chart1.Size = new System.Drawing.Size(250, 200);
                    chart1.Series.Add(num.ToString());
                    chart1.Series[num.ToString()].ChartArea        = "ChartArea1";
                    chart1.Series[num.ToString()].BorderWidth      = 1;
                    chart1.Series[num.ToString()].CustomProperties = "PointWidth=1";
                    chart1.Series[num.ToString()].BorderColor      = Color.Black;
                    chart1.ChartAreas[0].AxisX.LabelStyle.Format   = "{0:0.000}";
                    chart1.ChartAreas[0].AxisY.LabelStyle.Format   = "{0:0.000}";

                    if (g == k)
                    {
                        chart1.ChartAreas[0].AxisX.Minimum      = min;
                        chart1.ChartAreas[0].AxisX.Maximum      = part_arr.Max();
                        chart1.Series[num.ToString()].ChartType = SeriesChartType.Column;
                        for (int j = 0; j < numclass; j++)
                        {
                            double num1 = 0;
                            for (int i = 0; i < part_arr.Length; i++)
                            {
                                if ((part_arr[i] >= min) && (part_arr[i] <= (min + step + 0.00005)))
                                {
                                    num1++;
                                }
                            }
                            chart1.Series[num.ToString()].Points.AddXY(Math.Round(min + step / 2, 4), (num1 / part_arr.Length));
                            min = min + step;
                        }
                        CHARTS[k, g] = chart1;
                    }
                    else
                    {
                        chart1.Series[num.ToString()].ChartType = SeriesChartType.Point;
                        double[] X = NNData.PartArr(data.ARR, data.Length, g);
                        double[] Y = NNData.PartArr(data.ARR, data.Length, k);
                        for (int i = 0; i < X.Length; i++)
                        {
                            chart1.Series[num.ToString()].Points.AddXY(X[i], Y[i]);
                        }
                        CHARTS[k, g] = chart1;
                    }
                    num++;
                }
            }


            for (int i = 0; i < data.Num; i++)
            {
                for (int j = 0; j < data.Num; j++)
                {
                    tableLayoutPanel1.Controls.Add(CHARTS[i, j], i, j);
                }
            }
        }
Пример #12
0
        private void button29_Click(object sender, EventArgs e)
        {/*
          * if (domainUpDown1.Text == "" || domainUpDown2.Text == ""
          || comboBox1.Text == "" || domainUpDown1.Text == domainUpDown2.Text
          || ReturnByName(domainUpDown1.Text) == null
          || ReturnByName(domainUpDown2.Text) == null)
          ||{
          ||    MessageBox.Show("No parameters!");
          ||    return;
          ||}*/
            string RESULT = "";

            if (comboBox1.Text == "Багатовимірні середнi (рівні DC)")
            {
                NNData first  = ReturnByName(domainUpDown1.Text);
                NNData second = ReturnByName(domainUpDown2.Text);

                if (first.Num != second.Num)
                {
                    MessageBox.Show("not equal");
                    return;
                }
                double Vstat = Help.VStatistic(first, second);
                if (Vstat <= Quantil.XIquantil(first.Num))
                {
                    RESULT += "+" + Vstat.ToString() + "\n";
                }
                else
                {
                    RESULT += "-" + Vstat.ToString() + "\n";
                }
                label30.Text = RESULT;
            }
            else if (comboBox1.Text == "k n-вимірних середніх (розбіжні DC)")
            {
                double Vstat = Help.VStatistic(list);
                if (Vstat <= Quantil.XIquantil(list[0].Num))
                {
                    RESULT += "+" + Vstat.ToString() + "\n";
                }
                else
                {
                    RESULT += "-" + Vstat.ToString() + "\n";
                }
                label30.Text = RESULT;
            }
            else if (comboBox1.Text == "збіг DC")
            {
                double Vstat = Help.V2Statistic(list);
                if (Vstat <= Quantil.XIquantil(list[0].Num))
                {
                    RESULT += "+" + Vstat.ToString() + "\n";
                }
                else
                {
                    RESULT += "-" + Vstat.ToString() + "\n";
                }
                label30.Text = RESULT;
            }
            else
            {
                MessageBox.Show("kek");
                return;
            }
        }