private void HToolStripMenuItem_Click(object sender, EventArgs e) { bool[] KTurnOn = KTurnOnFound(); int w = 0; foreach (bool b in KTurnOn) { if (!b) { w++; } } double[,] SubK = InitialAnalysMultidimensionalData.SubK(IAM.K, KTurnOn); double[,] T = TFound(SubK, KTurnOn); double T_alf_v = Distributions.StudentQuantile(1 - IAM.ISA[0].alf.Q / 2, IAM.N - w - 2); bool[,] H = new bool[T.GetLength(0), T.GetLength(1)]; for (int i = 0; i < H.GetLength(0); i++) { for (int j = 0; j < H.GetLength(1); j++) { if (Math.Abs(T[i, j]) <= T_alf_v) { H[i, j] = true; } } } WraitH(CorelDataGridView, H, KTurnOn); }
internal VisualisationMultiDataForm(InitialAnalysMultidimensionalData IAM) { this.IAM = IAM; InitializeComponent(); WindowState = FormWindowState.Maximized; HeatMappictureBox.SizeMode = PictureBoxSizeMode.AutoSize; }
public Classterization(InitialAnalysMultidimensionalData IAM, ref List <InitialStatisticalAnalys> ML, ref List <double[]> undolist, ref TreeView treeView1) { this.IAM = IAM; this.ML = ML; this.undolist = undolist; this.treeView1 = treeView1; Data = new List <double[]>(); for (int i = 0; i < IAM.N; i++) { double[] value = new double[IAM.n]; for (int j = 0; j < IAM.n; j++) { value[j] = IAM.Xall[i, j]; } Data.Add(value); } InitializeComponent(); SetData(); if (IAM.n == 2) { chart.Series.Add(PaintData.CorelPaint(IAM.ISA[0].unsortl, IAM.ISA[1].unsortl, Color.Blue, "")); chart.Series.Add(ClassterCenterSer); } }
public MainComponentMethod(InitialAnalysMultidimensionalData IAM, ref List <InitialStatisticalAnalys> ML, ref List <double[]> undolist, ref TreeView treeView1) { this.IAM = IAM; this.ML = ML; this.undolist = undolist; this.treeView1 = treeView1; DataTabPage = TapPageCreate(); SetData(); if (IAM.n == 2) { Correlation_RegressionAnalysis CRA = new Correlation_RegressionAnalysis(new List <InitialStatisticalAnalys>() { IAM.ISA[0], IAM.ISA[1] }, new List <int>() { 0, 1 }, RegresTypeName.LineRegresion); picture.Image = PaintData.Paintf(CRA, picture.Width, picture.Height); } }
private InitialAnalysMultidimensionalData ReversTransform(InitialAnalysMultidimensionalData IAMIndepended, double[,] eightvector) { double[,] eightvectorClone = new double[eightvector.GetLength(1), IAMIndepended.Xall.GetLength(1)]; for (int r = 0; r < eightvectorClone.GetLength(0); r++) { for (int c = 0; c < eightvectorClone.GetLength(1); c++) { eightvectorClone[r, c] = eightvector[r, c]; } } double[,] X = Matrix.MultiplicMatrix(IAMIndepended.Xall, Matrix.TranspMatrix(eightvectorClone)); InitialAnalysMultidimensionalData result = new InitialAnalysMultidimensionalData(X, -1); if (IAM.n == 2) { double corel = IAM.K[0, 1]; double fi = Math.Atan(2 * corel * IAM.ISA[0].Gx.Q * IAM.ISA[1].Gx.Q / (Math.Pow(IAM.ISA[0].Gx.Q, 2) - Math.Pow(IAM.ISA[1].Gx.Q, 2))) / 2; picture.Image = PaintData.RotateImage(new Bitmap(picture.Image), -fi); } return(result); }
private void TToolStripMenuItem_Click(object sender, EventArgs e) { bool[] KTurnOn = KTurnOnFound(); double[,] SubK = InitialAnalysMultidimensionalData.SubK(IAM.K, KTurnOn); double[,] T = TFound(SubK, KTurnOn); WraitK(CorelDataGridView, T, KTurnOn); }
private double S0ij(InitialAnalysMultidimensionalData X, InitialAnalysMultidimensionalData Y, int i, int j, double N1, double N2) { double rez = 0; double xij = 0, yij = 0, xi = 0, xj = 0, yi = 0, yj = 0; xi = X.ISA[i].unsortl.Sum(); yi = Y.ISA[i].unsortl.Sum(); xj = X.ISA[j].unsortl.Sum(); yj = Y.ISA[j].unsortl.Sum(); for (int L = 0; L < N1; L++) { xij += X.ISA[i].unsortl[L] * X.ISA[j].unsortl[L]; } for (int L = 0; L < N2; L++) { yij += Y.ISA[i].unsortl[L] * Y.ISA[j].unsortl[L]; } rez = -(xi + yi) * (xj + yj) / (N1 + N2); rez += xij + yij; rez /= N1 + N2 - 2; return(rez); }
internal object[] SaveData(InitialAnalysMultidimensionalData IAMD) { this.ISA = IAMD.ISA; type = 2; comboBox1.Items.Clear(); Namelabel.Text = "Створення " + IAMD.ISA.Count + "-мірних даних";/* * comboBox1.Items.AddRange(Regex.Split(RegresTypeName.TypeRegresion, "\n")); * comboBox1.SelectedIndex = 0;*/ comboBox1.Visible = false; Q1label.Visible = true; Q1textBox.Visible = true; Q2label.Visible = true; Q2textBox.Visible = true; Q3label.Visible = false; Q3textBox.Visible = false; Nlabel.Visible = true; NtextBox.Visible = true; Nlabel.Text = "sigma e"; NtextBox.Text = "10"; Q1label.Text = "A"; Q1textBox.Text = ""; Q2label.Text = "A0"; Q2textBox.Text = ""; Q3label.Text = "c"; Q3textBox.Text = "1"; if (this.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return(null); } return(new object[] { RezDat, comboBox2.SelectedIndex }); }
public Classification(InitialAnalysMultidimensionalData IAM, int index) { this.IAM = IAM; n = IAM.n - 1; InitializeComponent(); InitializeData(index); NewDataDataGridView.ColumnCount = n; NewDataDataGridView.Rows.Add(); }
private double[,] xdF(InitialAnalysMultidimensionalData IAMD) { double[,] rez = new double[1, IAMD.n]; for (int i = 0; i < IAMD.E.Length; i++) { rez[0, i] = IAMD.E[i]; } return(rez); }
public FactorAnalysisMethod(InitialAnalysMultidimensionalData IAM, ref List <InitialStatisticalAnalys> ML, ref List <double[]> undolist, ref TreeView treeView1) { this.IAM = IAM; this.ML = ML; this.undolist = undolist; this.treeView1 = treeView1; DataTabPage = TapPageCreate(); SetData(); }
public Data SravnSredF(InitialAnalysMultidimensionalData X, InitialAnalysMultidimensionalData Y) { Data rez = new Data(); double[,] S0 = S0F(X, Y); double[,] S1 = S1F(X, Y); rez.Name = "Рівність багатомірних середніх при рівності DC матриці"; rez.Q = -(N1 + N2 - 2 - n / 2) * Math.Log(Matrix.Determinant(S1) / Matrix.Determinant(S0)); rez.QKvant = Hi.HIF(X.ISA[0].alf.Q, n); rez.H = rez.Q <= rez.QKvant; return(rez); }
public void IAMFound() { double[,] X = new double[data.Count, n]; for (int c = 0; c < n; c++) { for (int r = 0; r < data.Count; r++) { X[r, c] = data[r][c]; } } IAM = new InitialAnalysMultidimensionalData(X, -1); }
private double[,] S0F(InitialAnalysMultidimensionalData X, InitialAnalysMultidimensionalData Y) { int n = X.ISA.Count; double[,] rez = new double[n, n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { rez[i, j] = S0ij(X, Y, i, j, X.ISA[0].unsortl.Length, Y.ISA[0].unsortl.Length); } } return(rez); }
private void CorelAreachartPaint(InitialAnalysMultidimensionalData IAM, Color CorelCol, Color GistCol, Chart CorelChart, Color ColLine) { for (int i = 0; i < IAM.n; i++) { for (int j = 0; j < IAM.n; j++) { string ChartAreaName = j.ToString() + "_" + i.ToString(); ChartArea ChartArea1 = new ChartArea(ChartAreaName); ChartArea1.AxisX.LabelStyle.Enabled = false; ChartArea1.AxisY.LabelStyle.Enabled = false; CorelChart.ChartAreas.Add(ChartArea1); var po = CorelAreachart.ChartAreas[0].Position; Series ser; if (i != j) { InitialStatisticalAnalys ISAX = new InitialStatisticalAnalys(InitialStatisticalAnalys.StandData(IAM.ISA[i].unsortl, IAM.ISA[i].Gx.Q, IAM.ISA[i].Mx.Q)); InitialStatisticalAnalys ISAY = new InitialStatisticalAnalys(InitialStatisticalAnalys.StandData(IAM.ISA[j].unsortl, IAM.ISA[j].Gx.Q, IAM.ISA[j].Mx.Q)); ser = PaintData.CorelPaint(ISAX.unsortl, ISAY.unsortl, CorelCol, ChartAreaName); ser.MarkerStyle = MarkerStyle.Circle; CorelChart.Series.Add(ser); double Sz = 0; if (Correlation_RegressionAnalysis.KorelationZnach(IAM.K[i, j], IAM.N, IAM.ISA[0].alf.Q)) { List <Data> Param = Correlation_RegressionAnalysis.RegresParamFound( ISAX, ISAY, IAM.K[i, j], RegresTypeName.LineRegresion, ref Sz); Series serReg = PaintData.LineRegresPaint(ISAX.Min.Q, ISAX.Max.Q, Param[0].Q, Param[1].Q, ColLine, ChartAreaName + "Line"); serReg.ChartArea = ChartAreaName; CorelChart.Series.Add(serReg); } } else { ser = PaintData.GistogPaint(IAM.ISA[i], GistCol, ChartAreaName); CorelChart.Series.Add(ser); } ser.ChartArea = ChartAreaName; } } }
static public double Normalf(InitialAnalysMultidimensionalData IAM, double[] X) { double[,] Xm = new double[1, IAM.n]; double[,] E = new double[1, IAM.n]; for (int c = 0; c < IAM.n; c++) { E[0, c] = IAM.Ex[c]; Xm[0, c] = X[c] - IAM.Ex[c]; } double znam = Math.Sqrt(Math.Pow(2 * Math.PI, IAM.n) * Matrix.Determinant(IAM.DC)); double[,] XEX = Matrix.MultiplicNumber(Matrix.MultiplicMatrix( Matrix.MultiplicMatrix(Xm, Matrix.InverseMatrix(IAM.DC)), Matrix.TranspMatrix(Xm)) , -0.5); return(Math.Exp(XEX[0, 0]) / znam); }
private void CorelatioDataGridView_ColumnHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { bool[] b = new bool[CorelDataGridView.ColumnCount]; int size = 0; for (int i = 0; i < CorelDataGridView.ColumnCount; i++) { if (CorelDataGridView[i, i].Style.BackColor != Color.Red) { size++; b[i] = true; } } if (CorelDataGridView[e.ColumnIndex, 0].Style.BackColor != Color.Red) { b[e.ColumnIndex] = false; size--; if (size < 2) { return; } for (int i = 0; i < CorelDataGridView.ColumnCount; i++) { CorelDataGridView[i, e.ColumnIndex].Style.BackColor = Color.Red; CorelDataGridView[e.ColumnIndex, i].Style.BackColor = Color.Red; CorelDataGridView[i, e.ColumnIndex].Value = ""; CorelDataGridView[e.ColumnIndex, i].Value = ""; } } else { b[e.ColumnIndex] = true; size++; for (int i = 0; i < CorelDataGridView.ColumnCount; i++) { if (b[i]) { CorelDataGridView[i, e.ColumnIndex].Style.BackColor = Color.Green; CorelDataGridView[e.ColumnIndex, i].Style.BackColor = Color.Green; } } } CorelDataGridView.TopLeftHeaderCell.Value = Math.Round(Distributions.StudentQuantile(1 - IAM.ISA[0].alf.Q / 2, IAM.N - (b.Length - size) - 2), 4).ToString(); double[,] SubK = InitialAnalysMultidimensionalData.SubK(IAM.K, b); WraitK(CorelDataGridView, SubK, b); }
static public double[,] VFound(InitialAnalysMultidimensionalData IAM) { double[,] result = new double[IAM.n, IAM.n]; for (int k = 0; k < IAM.n; k++) { for (int p = 0; p < IAM.n; p++) { for (int i = 0; i < IAM.N; i++) { result[k, p] += (IAM.ISA[k].unsortl[i] - IAM.ISA[k].Mx.Q) * (IAM.ISA[p].unsortl[i] - IAM.ISA[p].Mx.Q); } } } V = result; return(result); }
private void ReversTransformValueToolStripMenuItem_Click(object sender, EventArgs e) { InitialAnalysMultidimensionalData IAMReverse = ReversTransform(IAMIndepended, IAM.eightvector); int MaxGroup = -1; for (int j = 0; j < ML.Count; j++) { MaxGroup = Math.Max(MaxGroup, ML[j].Group); } for (int i = 0; i < IAMReverse.n; i++) { IAMReverse.ISA[i].Group = MaxGroup + 1; ML.Add(IAMReverse.ISA[i]); undolist.Add(ML[ML.Count - 1].unsortl); } WraitData.RefreshList(treeView1, ML); }
private double[,] SdF(InitialAnalysMultidimensionalData IAMD) { double[,] rez; double[,] X = new double[IAMD.N, IAMD.n]; double[,] XT; double[,] Ex = xdF(IAMD); for (int i = 0; i < IAMD.n; i++) { for (int l = 0; l < IAMD.N; l++) { X[l, i] = IAMD.ISA[i].unsortl[l] - Ex[0, i]; } } XT = Matrix.TranspMatrix(X); rez = Matrix.MultiplicMatrix(XT, X); rez = Matrix.MultiplicNumber(rez, 1.0 / (IAMD.N - 1)); return(rez); }
public UniformityDoubleMultidimensionalData(List <InitialStatisticalAnalys> ISA, List <List <int> > ind) { X = new InitialAnalysMultidimensionalData(ISA, ind[0], 0); Y = new InitialAnalysMultidimensionalData(ISA, ind[1], 0); n = ind[0].Count; N1 = ISA[ind[0][0]].unsortl.Length; N2 = ISA[ind[1][0]].unsortl.Length; for (int i = 1; i < n; i++) { if (N1 != ISA[ind[0][i]].unsortl.Length || N2 != ISA[ind[0][i]].unsortl.Length) { MessageBox.Show("Not correct input data", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } Refresh(); }
private void ParalCoordchartPaint(InitialAnalysMultidimensionalData IAM, Chart ParalCoordchart) { ParalCoordchart.Series.Clear(); for (int row = 0; row < IAM.N; row++) { Color color = Color.Red;//ColorFromHSV((360.0 * row / IAM.N),1,1); Series Line = new Series(row.ToString()); Line.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; Line.Color = color; for (int col = 0; col < IAM.n; col++) { Line.Points.AddXY(col + 1, 2 * (IAM.ISA[col].unsortl[row] - IAM.ISA[col].Min.Q) / IAM.ISA[col].Len.Q - 1); } ParalCoordchart.Series.Add(Line); } ParalCoordchart.ChartAreas[0].AxisY.Minimum = -1; ParalCoordchart.ChartAreas[0].AxisY.Maximum = 1; ParalCoordchart.ChartAreas[0].AxisX.Minimum = 1; ParalCoordchart.ChartAreas[0].AxisX.Maximum = IAM.n; }
private void UppperValueToolStripMenuItem_Click(object sender, EventArgs e) { bool[] KTurnOn = KTurnOnFound(); int w = 0; foreach (bool b in KTurnOn) { if (!b) { w++; } } double[,] SubK = InitialAnalysMultidimensionalData.SubK(IAM.K, KTurnOn); double[,] V2 = new double[SubK.GetLength(0), SubK.GetLength(1)]; double[,] BV = new double[SubK.GetLength(0), SubK.GetLength(1)]; double U = Distributions.NormalQuantile(1 - IAM.ISA[0].alf.Q / 2); U /= (IAM.N - w - 3); for (int col = 0; col < SubK.GetLength(1); col++) { for (int row = 0; row < SubK.GetLength(0); row++) { if (KTurnOn[col] && KTurnOn[row]) { V2[row, col] = Math.Log((1 + SubK[row, col]) / (1 - SubK[row, col])) / 2 + U; double exp = Math.Exp(2 * V2[row, col]); if (double.IsInfinity(exp)) { BV[row, col] = 1; } else { BV[row, col] = (exp - 1.0) / (exp + 1.0); } } } } WraitK(CorelDataGridView, BV, KTurnOn); }
private void RadarchartPaint(InitialAnalysMultidimensionalData IAM, Color RadarCol, int n, Chart RadarChart) { Font font = new Font("Times New Roman", 14.0f); RadarChart.ChartAreas.Clear(); RadarChart.Series.Clear(); RadarChart.Titles.Clear(); for (int i = 0; i < n && i + NumRadaraData < IAM.N; i++) { string ChartAreaName = i.ToString(); Title titl = new Title((i + 1 + NumRadaraData).ToString(), Docking.Bottom, font, Color.DarkBlue); titl.DockedToChartArea = ChartAreaName; RadarChart.Titles.Add(titl); ChartArea ChartArea1 = new ChartArea(ChartAreaName); ChartArea1.AxisY.Maximum = 1; ChartArea1.AxisX.LabelStyle.Enabled = false; ChartArea1.AxisY.LabelStyle.Enabled = false; ChartArea1.AxisY.MajorGrid.Enabled = false; RadarChart.ChartAreas.Add(ChartArea1); Series ser = new Series(ChartAreaName + "_Ser"); ser.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Radar; ser["PointWidth"] = "1"; ser.BorderWidth = 1; ser.Color = RadarCol; ser.BorderColor = Color.Black; for (int col = 0; col < IAM.n; col++) { ser.Points.AddXY(col, (IAM.ISA[col].unsortl[i + NumRadaraData] - IAM.ISA[col].Min.Q) / IAM.ISA[col].Len.Q); } ser.ChartArea = ChartAreaName; RadarChart.Series.Add(ser); } }
private void HeatMappictureBoxPaint(InitialAnalysMultidimensionalData IAM, Color MaxValueCol, PictureBox HeatMapPuctureBox) { Font font = new Font("Times New Roman", 14.0f); int width = panel1.Width - 20; int height = 25 * IAM.N; double stepcol = width / IAM.n; double steprow = height / IAM.N; Bitmap BM = new Bitmap(width, height); using (Graphics gr = Graphics.FromImage(BM)) { for (int row = 0; row < IAM.N; row++) { for (int col = 0; col < IAM.n; col++) { double s = (IAM.ISA[col].unsortl[row] - IAM.ISA[col].Min.Q) / IAM.ISA[col].Len.Q; if (s == 0) { } SolidBrush f = new SolidBrush( Color.FromArgb( 255 - (int)((255 - MaxValueCol.R) * s), 255 - (int)((255 - MaxValueCol.G) * s), 255 - (int)((255 - MaxValueCol.B) * s))); gr.FillRectangle(f, (float)(col * stepcol), (float)(row * steprow), (float)((col + 1) * stepcol), (float)((row + 1) * steprow)); } gr.DrawString((row + 1).ToString(), font, Brushes.Green, 10, (float)(row * steprow)); } gr.Dispose(); } HeatMapPuctureBox.Image = BM; }
public SubCorelationClass(InitialAnalysMultidimensionalData IAM) { this.IAM = IAM; CorelTabPage = TapPageCreate(); }
private void BottomValueToolStripMenuItem_Click(object sender, EventArgs e) { try { MinimalDispersValue = Convert.ToDouble(MinimalDispers.Text); } catch { MinimalDispersValue = 0; } if (IAM.n == 2) { double corel = IAM.K[0, 1]; double fi = Math.Atan(2 * corel * IAM.ISA[0].Gx.Q * IAM.ISA[1].Gx.Q / (Math.Pow(IAM.ISA[0].Gx.Q, 2) - Math.Pow(IAM.ISA[1].Gx.Q, 2))) / 2; picture.Image = PaintData.RotateImage(new Bitmap(picture.Image), fi); } double[,] Xallstandart = new double[IAM.Xall.GetLength(0), IAM.Xall.GetLength(1)]; for (int i = 0; i < IAM.Xall.GetLength(0); i++) { for (int j = 0; j < IAM.Xall.GetLength(1); j++) { Xallstandart[i, j] = (IAM.Xall[i, j] - IAM.Ex[j]) /* / IAM.ISA[j].Gx.Q*/; } } double[,] X = Matrix.MultiplicMatrix(Xallstandart, IAM.eightvector); int MaxGroup = -1; for (int j = 0; j < ML.Count; j++) { MaxGroup = Math.Max(MaxGroup, ML[j].Group); } List <int> index = new List <int>(); for (int i = 0; i < IAM.n; i++) { List <double> Data = new List <double>(); for (int j = 0; j < IAM.N; j++) { Data.Add(X[j, i]); } InitialStatisticalAnalys ISA = new InitialStatisticalAnalys(Data, MaxGroup + 1); if (ISA.Dx.Q >= MinimalDispersValue) { ML.Add(ISA); index.Add(ML.Count - 1); undolist.Add(ML[ML.Count - 1].unsortl); } } WraitData.RefreshList(treeView1, ML); IAMIndepended = new InitialAnalysMultidimensionalData(ML, index, -1); IAMIndependedToRevers = new InitialAnalysMultidimensionalData(X, 1); ReversTransformValueToolStripMenuItem.Visible = true; Procent = new double[IAM.n]; for (int c = 0; c < IAM.n; c++) { for (int r = 0; r < IAMIndepended.Xall.GetLength(1); r++) { Procent[c] += Math.Pow(IAM.eightvector[r, c], 2); } Procent[c] *= 100; } DataGridView.Rows.Clear(); SetData(); SetNextData(); }