MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Histogram and BinCounts inconsistency

  • To: mathgroup at
  • Subject: [mg55236] Histogram and BinCounts inconsistency
  • From: "J.S. Theriault" <jstheriault at>
  • Date: Thu, 17 Mar 2005 03:29:32 -0500 (EST)
  • Sender: owner-wri-mathgroup at

It seems that Graphics`Graphics`Histogram and 
Statistics`DataManipulation`BinCounts have inconsistent bin limits. 
Histogram includes the lower limit and not the higher limit of each bin, 
and BinCounts does the opposite.

To illustrate:

data = Range[15]
categories = Range[0,20,5]

will show 4 bars on the histogram with the following counts: 4, 5, 5, 1
 From this we can infer that the limits for each bar are
categories[[n]] <= x < categories[[n+1]]

Doing a 'manual' histogram with BinCounts:

   data, {0, 20, 5}],
   FrequencyData -> True,
   HistogramCategories -> categories]

Yields 4 bars with the following counts: 5, 5, 5, which is consistent 
with BinCounts documentation that states

The bin boundaries are {xmin < x <= xmin + dx, ..., xmax - dx < x <= xmax}

So, Histogram includes the lower limit and not the higher limit, and 
BinCounts does the opposite.

Wouldn't it be nice to have the option of specifying the bin membership 
function? Something like: BinCounts[data, {0,20,5}, (#1 <= #2 < #3)&]


  • Prev by Date: Re: question: re-organising equations
  • Next by Date: Re: GridLines
  • Previous by thread: Re: J/Link problem on Mac OS X
  • Next by thread: Front End Help Browser Bug