Ejemplo n.º 1
0
        public static double[] Min(SPC.Base.Interface.IDataTable <DataRow> input, string[] columns)
        {
            int count = input.RowCount;

            double[] result = new double[count];
            int      length = columns.Length;
            int      i, j;
            double   min, temp;
            DataRow  temprow;

            for (i = 0; i < count; i++)
            {
                min     = double.MaxValue;
                temprow = input[i];
                for (j = 0; j < length; j++)
                {
                    temp = temprow[columns[j]].ConvertToDouble();
                    if (temp < min)
                    {
                        min = temp;
                    }
                }
                result[i] = min;
            }
            return(result);
        }
Ejemplo n.º 2
0
        public static double[] Max(SPC.Base.Interface.IDataTable <DataRow> input, string[] columns)
        {
            int count  = input.RowCount;
            int length = columns.Length;

            double[] result = new double[length];
            int      i, j;
            double   temp;
            DataRow  temprow;

            for (j = 0; j < length; j++)
            {
                result[j] = double.MinValue;
            }
            for (i = 0; i < count; i++)
            {
                temprow = input[i];
                for (j = 0; j < length; j++)
                {
                    temp = temprow[columns[j]].ConvertToDouble();
                    if (temp > result[j])
                    {
                        result[j] = temp;
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 3
0
        public static void F1T2(SPC.Base.Interface.IDataTable <DataRow> sourcedata, string[] sourcecolumns, string[] targetcolumns, double arg_1, double arg_2)
        {
            var mins        = ColumnCalculate.Min(sourcedata, sourcecolumns);
            var maxs        = ColumnCalculate.Max(sourcedata, sourcecolumns);
            int rowcount    = sourcedata.RowCount;
            int columncount = sourcecolumns.Length;

            double[] ranges = new double[columncount];
            int      i, j;
            DataRow  temprow;
            double   r = arg_2 - arg_1;

            for (j = 0; j < columncount; j++)
            {
                if (!sourcedata.ContainsColumn(targetcolumns[j]))
                {
                    sourcedata.AddColumn(targetcolumns[j], typeof(double));
                }
                ranges[j] = maxs[j] - mins[j];
            }

            for (i = 0; i < rowcount; i++)
            {
                temprow = sourcedata[i];
                for (j = 0; j < columncount; j++)
                {
                    temprow[targetcolumns[j]] = ((temprow[sourcecolumns[j]].ConvertToDouble() - mins[j]) * r) / ranges[j] + arg_1;
                }
            }
        }
Ejemplo n.º 4
0
        public static void ZScore(SPC.Base.Interface.IDataTable <DataRow> sourcedata, string[] sourcecolumns, string[] targetcolumns)
        {
            var     avgs = ColumnCalculate.Avg(sourcedata, sourcecolumns);
            var     stdevs = ColumnCalculate.Stdev(sourcedata, sourcecolumns, avgs);
            int     rowcount = sourcedata.RowCount;
            int     columncount = sourcecolumns.Length;
            int     i, j;
            DataRow temprow;

            foreach (var targetcolumn in targetcolumns)
            {
                if (!sourcedata.ContainsColumn(targetcolumn))
                {
                    sourcedata.AddColumn(targetcolumn, typeof(double));
                }
            }
            for (i = 0; i < rowcount; i++)
            {
                temprow = sourcedata[i];
                for (j = 0; j < columncount; j++)
                {
                    temprow[targetcolumns[j]] = (temprow[sourcecolumns[j]].ConvertToDouble() - avgs[j]) / stdevs[j];
                }
            }
        }
Ejemplo n.º 5
0
        public static double[] Stdev(SPC.Base.Interface.IDataTable <DataRow> input, string[] columns)
        {
            int count = input.RowCount;

            double[] result = new double[count];
            int      length = columns.Length;
            int      i, j;
            double   sum;
            double   avg;
            double   std;
            DataRow  temprow;

            for (i = 0; i < count; i++)
            {
                sum     = 0;
                temprow = input[i];
                for (j = 0; j < length; j++)
                {
                    sum += temprow[columns[j]].ConvertToDouble();
                }
                avg = sum / length;
                std = 0;
                for (j = 0; j < length; j++)
                {
                    std += Math.Pow(temprow[columns[j]].ConvertToDouble() - avg, 2);
                }
                result[i] = Math.Pow(std / length, 0.5);
            }
            return(result);
        }
Ejemplo n.º 6
0
        public static double[] Stdev(SPC.Base.Interface.IDataTable <DataRow> input, string[] columns, double[] avgs)
        {
            int count  = input.RowCount;
            int length = columns.Length;

            if (avgs.Length != length)
            {
                return(Stdev(input, columns));
            }
            double[] result = new double[length];
            int      i, j;
            DataRow  temprow;

            for (i = 0; i < count; i++)
            {
                temprow = input[i];
                for (j = 0; j < length; j++)
                {
                    result[j] += Math.Pow(temprow[columns[j]].ConvertToDouble() - avgs[j], 2);
                }
            }
            for (j = 0; j < length; j++)
            {
                result[j] = Math.Pow(result[j] / count, 0.5);
            }
            return(result);
        }
Ejemplo n.º 7
0
        public static double[] Mid(SPC.Base.Interface.IDataTable <DataRow> input, string[] columns)
        {
            int count = input.RowCount;

            double[] result = new double[count];
            int      length = columns.Length;
            int      i, j;
            double   temp;
            DataRow  temprow;
            SortedList <double, double> list;

            for (i = 0; i < count; i++)
            {
                temprow = input[i];
                list    = new SortedList <double, double>();
                for (j = 0; j < length; j++)
                {
                    temp = temprow[columns[j]].ConvertToDouble();
                    list.Add(temp, temp);
                }
                if (length % 2 == 0)
                {
                    result[i] = (list.Keys[length / 2] + list.Keys[length / 2 - 1]) / 2;
                }
                else
                {
                    result[i] = list.Keys[length / 2];
                }
            }
            return(result);
        }
Ejemplo n.º 8
0
 public void Init(SPC.Base.Interface.IDataTable <DataRow> data)
 {
     this.Data = data;
     this.listBoxControl1.Items.Clear();
     this.columnList = Data.GetColumnsList();
     foreach (string column in columnList)
     {
         this.listBoxControl1.Items.Add(column);
     }
 }
Ejemplo n.º 9
0
 public void Init(DataSet result, SPC.Base.Interface.IDataTable <DataRow> data)
 {
     this.Result = result;
     this.Data   = data;
     this.gridControl2.DataSource = Result;
     this.gridControl2.DataMember = "Results";
     this.gridControl1.DataSource = Result;
     this.gridControl1.DataMember = "OverView";
     this.gridView2.Columns.ColumnByFieldName("序号").Visible = false;
     this.gridView2.GroupSummary.Clear();
     this.gridView2.GroupSummary.Add(new DevExpress.XtraGrid.GridGroupSummaryItem(DevExpress.Data.SummaryItemType.Count, this.gridView2.Columns[0].FieldName, null, "Count:{0}"));
     gridView1.FocusedRowHandle = 0;
     (this.gridView2.DataSource as DataView).RowFilter = "序号 = " + gridView1.GetDataRow(0)[0].ToString();
 }
Ejemplo n.º 10
0
 public void Init(DataSet result,SPC.Base.Interface.IDataTable<DataRow> data)
 {
     this.Result = result;
     this.Data = data;
     this.gridControl2.DataSource = Result;
     this.gridControl2.DataMember = "Results";
     this.gridControl1.DataSource = Result;
     this.gridControl1.DataMember = "OverView";
     this.gridView2.Columns.ColumnByFieldName("序号").Visible = false;
     this.gridView2.GroupSummary.Clear();
     this.gridView2.GroupSummary.Add(new DevExpress.XtraGrid.GridGroupSummaryItem(DevExpress.Data.SummaryItemType.Count, this.gridView2.Columns[0].FieldName, null, "Count:{0}"));
     gridView1.FocusedRowHandle = 0;
     (this.gridView2.DataSource as DataView).RowFilter = "序号 = " + gridView1.GetDataRow(0)[0].ToString();
 }
Ejemplo n.º 11
0
        public static double[] Count(SPC.Base.Interface.IDataTable <DataRow> input, string[] columns)
        {
            int count  = input.RowCount;
            int length = columns.Length;

            double[] result = new double[length];
            int      i;

            for (i = 0; i < length; i++)
            {
                result[i] = count;
            }
            return(result);
        }
Ejemplo n.º 12
0
        public static double[] QuadraticSum(SPC.Base.Interface.IDataTable <DataRow> input, string[] columns)
        {
            int count  = input.RowCount;
            int length = columns.Length;

            double[] result = new double[length];
            int      i, j;
            DataRow  temprow;

            for (i = 0; i < count; i++)
            {
                temprow = input[i];
                for (j = 0; j < length; j++)
                {
                    result[j] += Math.Pow(temprow[columns[j]].ConvertToDouble(), 2);
                }
            }
            return(result);
        }
Ejemplo n.º 13
0
        public static double[] IsNull(SPC.Base.Interface.IDataTable <DataRow> input, string[] columns)
        {
            int count  = input.RowCount;
            int length = columns.Length;

            double[] result = new double[length];
            int      i, j;
            DataRow  temprow;

            for (i = 0; i < count; i++)
            {
                temprow = input[i];
                for (j = 0; j < length; j++)
                {
                    if (temprow[columns[j]] == null || temprow[columns[j]] == DBNull.Value)
                    {
                        result[j]++;
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 14
0
        public static double[] Avg(SPC.Base.Interface.IDataTable <DataRow> input, string[] columns)
        {
            int count = input.RowCount;

            double[] result = new double[count];
            int      length = columns.Length;
            int      i, j;
            double   sum;
            DataRow  temprow;

            for (i = 0; i < count; i++)
            {
                sum     = 0;
                temprow = input[i];
                for (j = 0; j < length; j++)
                {
                    sum += temprow[columns[j]].ConvertToDouble();
                }
                result[i] = sum / length;
            }
            return(result);
        }
Ejemplo n.º 15
0
        public static void M1D2(SPC.Base.Interface.IDataTable <DataRow> sourcedata, string[] sourcecolumns, string[] targetcolumns, double arg_1, double arg_2)
        {
            int     rowcount = sourcedata.RowCount;
            int     columncount = sourcecolumns.Length;
            int     i, j;
            DataRow temprow;

            foreach (var targetcolumn in targetcolumns)
            {
                if (!sourcedata.ContainsColumn(targetcolumn))
                {
                    sourcedata.AddColumn(targetcolumn, typeof(double));
                }
            }
            for (i = 0; i < rowcount; i++)
            {
                temprow = sourcedata[i];
                for (j = 0; j < columncount; j++)
                {
                    temprow[targetcolumns[j]] = (temprow[sourcecolumns[j]].ConvertToDouble() - arg_1) / arg_2;
                }
            }
        }
Ejemplo n.º 16
0
 public void Init(SPC.Base.Interface.IDataTable<DataRow> data)
 {
     this.Data = data;
     this.listBoxControl1.Items.Clear();
     this.columnList = Data.GetColumnsList();
     foreach (string column in columnList)
     {
         this.listBoxControl1.Items.Add(column);
     }
 }