コード例 #1
0
ファイル: Histogram1D_Base.cs プロジェクト: sjvannTMU/Sage
        /// <summary>
        /// Returns the index of the bin that contains the most entries, selected from
        /// a specified set of bins.
        /// </summary>
        /// <param name="hbc">The <see cref="HistogramBinCategory"/> that specifies the bins of interest.</param>
        /// <returns>The indexes of the bin that contains the fewest entries.</returns>
        public int[] SmallestBin(HistogramBinCategory hbc)
        {
            int smallestBinNum   = 0;
            int smallestBinCount = int.MaxValue;

            if (hbc == HistogramBinCategory.InRange || hbc == HistogramBinCategory.All)
            {
                smallestBinNum   = SmallestBin(new[] { 0 }, new[] { m_bins.Length })[0];
                smallestBinCount = m_bins[smallestBinNum];
            }

            if (hbc == HistogramBinCategory.OffScaleLow || hbc == HistogramBinCategory.All)
            {
                if (LowBin < smallestBinCount)
                {
                    smallestBinNum   = int.MinValue;
                    smallestBinCount = LowBin;
                }
            }
            if (hbc == HistogramBinCategory.OffScaleHigh || hbc == HistogramBinCategory.All)
            {
                if (HighBin < smallestBinCount)
                {
                    smallestBinNum = int.MaxValue;
                }
            }
            return(new[] { smallestBinNum });
        }
コード例 #2
0
        public override object SumEntries(HistogramBinCategory hbc)
        {
            long sumEntries = 0;
            bool sumLow     = false;
            bool sumHigh    = false;
            bool inRange    = hbc == HistogramBinCategory.InRange || hbc == HistogramBinCategory.All;

            if (hbc == HistogramBinCategory.OffScaleLow || hbc == HistogramBinCategory.All)
            {
                sumLow = true;
            }
            if (hbc == HistogramBinCategory.OffScaleHigh || hbc == HistogramBinCategory.All)
            {
                sumHigh = true;
            }

            TimeSpan[] data      = (TimeSpan[])m_rawData;
            TimeSpan   lowBound  = (TimeSpan)m_lowBound;
            TimeSpan   highBound = (TimeSpan)m_highBound;

            foreach (TimeSpan val in data)
            {
                if (val < lowBound)
                {
                    if (sumLow)
                    {
                        sumEntries += val.Ticks;
                    }
                }
                else if (val >= highBound)
                {
                    if (sumHigh)
                    {
                        sumEntries += val.Ticks;
                    }
                }
                else
                {
                    if (inRange)
                    {
                        sumEntries += val.Ticks;
                    }
                }
            }
            return(TimeSpan.FromTicks(sumEntries));
        }
コード例 #3
0
ファイル: Histogram1D_Double.cs プロジェクト: sjvannTMU/Sage
        public override object SumEntries(HistogramBinCategory hbc)
        {
            double sumEntries = 0.0;
            bool   sumLow     = false;
            bool   sumHigh    = false;

            if (hbc == HistogramBinCategory.OffScaleLow || hbc == HistogramBinCategory.All)
            {
                sumLow = true;
            }
            if (hbc == HistogramBinCategory.OffScaleHigh || hbc == HistogramBinCategory.All)
            {
                sumHigh = true;
            }
            bool inRange = hbc == HistogramBinCategory.InRange || hbc == HistogramBinCategory.All;

            double[] data      = (double[])m_rawData;
            double   lowBound  = (double)m_lowBound;
            double   highBound = (double)m_highBound;

            foreach (double val in data)
            {
                if (val < lowBound)
                {
                    if (sumLow)
                    {
                        sumEntries += val;
                    }
                }
                else if (val >= highBound)
                {
                    if (sumHigh)
                    {
                        sumEntries += val;
                    }
                }
                else
                {
                    if (inRange)
                    {
                        sumEntries += val;
                    }
                }
            }
            return(sumEntries);
        }
コード例 #4
0
ファイル: Histogram1D_Base.cs プロジェクト: sjvannTMU/Sage
        /// <summary>
        /// Counts the number of entries in a given range (low bin, in-band bins or high bin.)
        /// </summary>
        /// <param name="hbc">An enumerator that describes whether the count is for low, in-band, or high bins.</param>
        /// <returns>The number of entries that fall in the specified range.</returns>
        public int CountEntries(HistogramBinCategory hbc)
        {
            int nEntries = 0;

            if (hbc == HistogramBinCategory.OffScaleLow || hbc == HistogramBinCategory.All)
            {
                nEntries += LowBin;
            }
            if (hbc == HistogramBinCategory.OffScaleHigh || hbc == HistogramBinCategory.All)
            {
                nEntries += HighBin;
            }
            if (hbc == HistogramBinCategory.InRange || hbc == HistogramBinCategory.All)
            {
                nEntries += CountEntries(new[] { 0 }, new[] { NumBins });
            }
            return(nEntries);
        }
コード例 #5
0
ファイル: Histogram1D_Base.cs プロジェクト: sjvannTMU/Sage
 /// <summary>
 /// Returns the sum of values in all of the bins identified by the given <see cref="HistogramBinCategory"/>.
 /// </summary>
 /// <param name="hbc">The HistogramBinCategory.</param>
 /// <returns>The sum of values.</returns>
 public abstract object SumEntries(HistogramBinCategory hbc);
コード例 #6
0
 /// <summary>
 /// Returns the sum of values in all of the bins identified by the given <see cref="Highpoint.Sage.Mathematics.HistogramBinCategory"/>.
 /// </summary>
 /// <param name="hbc">The HistogramBinCategory.</param>
 /// <returns>The sum of values.</returns>
 public override object SumEntries(HistogramBinCategory hbc)
 {
     // TODO:  Add Histogram1D.SumEntries implementation
     return(0);
 }