예제 #1
0
        // Normalize Array 0 - 1
        public double[] Normalize(double[] buffer, int size)
        {
            int    i;
            MMPair minmax = GetMinMax(buffer, size);

            double[] output = new double[size];

            for (i = 0; i < size; i++)
            {
                output[i] = (buffer[i] - minmax.min) / (minmax.max - minmax.min);
            }

            return(output);
        }
예제 #2
0
        private double[] HSMakeBins(double[] buffer, int size)
        {
            int bins = (int)Math.Ceiling(Math.Pow(size, 1.0 / 3.0) * 2); // Rice's rule

            MMPair minmax = GetMinMax(buffer, size);

            double width = (minmax.max - minmax.min) / bins;

            double[] intervals = new double[bins * 2];
            intervals[0] = minmax.min;
            intervals[1] = minmax.min + width;

            for (int i = 2; i < intervals.Length - 1; i += 2)
            {
                intervals[i]     = intervals[i - 1];
                intervals[i + 1] = intervals[i] + width;
            }

            intervals[0] = Math.Floor(minmax.min);
            intervals[intervals.Length - 1] = Math.Ceiling(minmax.max);

            return(intervals);
        }