MathGroup Archive 2005

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

Search the Archive

Histogram and BinCounts inconsistency

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

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]
Histogram[data,HistogramCategories->categories]

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:

Histogram[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)&]

Cheers
-js


  • 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