public void Scale(float min, float max, int step, int sdNumber)
        {
            var   vv     = Metric.GetVector(0, step.ToString(), ":");
            var   stat   = MyStatisticsMath.SimpleStatistics(vv);
            float vmax   = (float)(stat.Average + sdNumber * stat.StandardDeviation);
            float vmin   = (float)(stat.Average - sdNumber * stat.StandardDeviation);
            float vdelta = vmax - vmin;
            float ndelta = max - min;
            float value  = 0;

            for (int i = 0; i < vv.Length; i++)
            {
                value = Metric[0, step, i];
                if (value < vmin)
                {
                    Metric[0, step, i] = min;
                }
                else if (value > vmax)
                {
                    Metric[0, step, i] = max;
                }
                else
                {
                    Metric[0, step, i] = min + (value - vmin) / vdelta * ndelta;
                }
            }
        }
        public StatisticsInfo GetValueStatistics(ObservationSeries series)
        {
            string sql = string.Format("select DateTimeUTC, DataValue from DataValues where SiteID={0} and VariableID={1} order by DateTimeUTC",
                                       series.SiteID, series.VariableID);
            var dt    = ODMDB.QueryDataTable(sql).AsEnumerable();
            var dates = from dr in dt select dr.Field <DateTime>("DateTimeUTC");

            var values = from dr in dt select dr.Field <double>("DataValue");

            var filtered = from vv in values where vv != 0 select vv;
            var info     = MyStatisticsMath.SimpleStatistics(filtered.ToArray());

            return(info);
        }
        public void Scale(int step, float min, float max)
        {
            var vv   = Metric.GetVector(0, step.ToString(), ":");
            var stat = MyStatisticsMath.SimpleStatistics(vv);

            float vmax   = (float)stat.Max;
            float vmin   = (float)stat.Min;
            float vdelta = vmax - vmin;
            float ndelta = max - min;

            for (int i = 0; i < vv.Length; i++)
            {
                Metric[0, step, i] = min + (Metric[0, step, i] - vmin) / vdelta * ndelta;
            }
        }