Пример #1
0
 /// <summary>
 /// Creates a histogram with the given number of bins.
 /// </summary>
 /// <param name="binCount">The number of bins.</param>
 /// <remarks>
 /// <para>By default, the bin borders are the integers, i.e. values in [0, 1) fall into bin 0, values in [1, 2) fall
 /// into bin 1, etc.</para>
 /// </remarks>
 /// <exception cref="ArgumentOutOfRangeException"><paramref name="binCount"/> is less than 1.</exception>
 public Histogram(int binCount)
 {
     if (binCount < 1)
     {
         throw new ArgumentOutOfRangeException("binCount");
     }
     double[] borders = new double[binCount + 1];
     for (int i = 0; i < borders.Length; i++)
     {
         borders[i] = i;
     }
     storage = new HistogramStorage(borders);
     bins    = new HistogramBinsCollection(storage);
 }
Пример #2
0
 /// <summary>
 /// Create a histogram with the given bin borders.
 /// </summary>
 /// <param name="binBorders">A list of bin borders.</param>
 /// <exception cref="ArgumentNullException"><paramref name="binBorders"/> is null.</exception>
 /// <exception cref="ArgumentException"><paramref name="binBorders"/> has less than two values, or the values are not ordered.</exception>
 public Histogram(IList <double> binBorders)
 {
     if (binBorders == null)
     {
         throw new ArgumentNullException("binBorders");
     }
     if (binBorders.Count < 2)
     {
         throw new ArgumentException("The bin borders list must be at least two elements long.", "binBorders");
     }
     if (!ValidateBorderMononicity(binBorders))
     {
         throw new ArgumentException("The values in the bin borders list must increase strictly monotonically.", "binBorders");
     }
     double[] borders = new double[binBorders.Count];
     binBorders.CopyTo(borders, 0);
     storage = new HistogramStorage(borders);
     bins    = new HistogramBinsCollection(storage);
 }