public static StatisticsInfo ComplexStatistics(float[,] values)
        {
            StatisticsInfo info = SimpleStatistics(values, float.NaN);

            info.StandardDeviation = StandardDeviation(values);
            return(info);
        }
        public static StatisticsInfo SimpleStatistics(double[,] values, double noDataValue)
        {
            StatisticsInfo info = new StatisticsInfo();

            info.Max         = float.PositiveInfinity;
            info.Min         = float.NegativeInfinity;
            info.NoDataValue = noDataValue;
            info.Average     = 0;
            double sum   = 0;
            int    count = 0;

            foreach (double f in values)
            {
                if (f == noDataValue)
                {
                    continue;
                }
                if (f > info.Max)
                {
                    info.Max = f;
                }
                if (f < info.Min)
                {
                    info.Min = f;
                }
                sum += f;
                count++;
            }
            if (count > 0)
            {
                info.Average = sum / count;
            }
            return(info);
        }
        public static StatisticsInfo ComplexStatistics(float[, ,] values, int layerIndex, int zindex, float noDataValue)
        {
            StatisticsInfo info = SimpleStatistics(values, layerIndex, zindex, noDataValue);

            info.StandardDeviation = StandardDeviation(values, layerIndex, zindex);
            return(info);
        }
        public static StatisticsInfo SimpleStatistics(double[] vector)
        {
            StatisticsInfo info = new StatisticsInfo();

            info.Max               = vector.Max();
            info.Min               = vector.Min();
            info.Average           = vector.Average();
            info.StandardDeviation = StandardDeviation(vector);
            info.Count             = vector.Length;
            return(info);
        }
        public static StatisticsInfo SimpleStatistics(float[, ,] values, int layerIndex, int zindex, float noDataValue)
        {
            StatisticsInfo info = new StatisticsInfo();

            info.Max         = float.NegativeInfinity;
            info.Min         = float.PositiveInfinity;
            info.NoDataValue = noDataValue;
            info.Average     = 0;
            double sum   = 0;
            int    count = 0;
            int    row   = values.GetLength(0);
            int    col   = values.GetLength(1);

            for (int i = 0; i < row; i++)
            {
                float f = values[i, layerIndex, zindex];
                if (f == noDataValue)
                {
                    continue;
                }
                if (f > info.Max)
                {
                    info.Max = f;
                }
                if (f < info.Min)
                {
                    info.Min = f;
                }
                sum += f;
                count++;
            }

            if (count > 0)
            {
                info.Average = sum / count;
            }
            return(info);
        }