Exemplo n.º 1
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;
                }
            }
        }
Exemplo n.º 2
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];
                }
            }
        }