MathGroup Archive 2002

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

Search the Archive

Re: Error in BinCounts function?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg36570] Re: Error in BinCounts function?
  • From: "P.J. Hinton" <paulh at wolfram.com>
  • Date: Fri, 13 Sep 2002 01:13:28 -0400 (EDT)
  • Organization: "Wolfram Research, Inc."
  • Sender: owner-wri-mathgroup at wolfram.com

In [mg36515], "Mark D. Normand" <mnormand at foodsci.umass.edu> writes:

> It seems there is an error in the BinCounts function of Mathematica's
> standard <<Statistics`DataManipulation` package where it sometimes
> returns one more than the expected number of histogram bins.  An example
> of this is shown in the notebook code below where the comment in the
> last notebook cell explicitly describes the problem.  If anyone can
> explain this behavior it would be appreciated, otherwise Wolfram
> Research should be made aware of this "feature" of the function when it
> is called as: BinCounts[{x1, x2, ...}, {xmin, xmax, dx}]

A developer of Mathematica's Standard Packages has requested that this
response be posted to the forum:

[begin developer's comments]

Note that if you don't apply N when computing datBinWidth, you will always
get the expected number of bins; i.e., datBinWidth = (datMax -
datMin)/datBins (assuming datMax and datMin are also exact numbers).

Given input {xmin, xmax, dx}, BinCounts determines the number of bins to
be computed via Ceiling[(xmax - xmin)/dx]. For numericalized values, it's
possible for dx to end up such that the Ceiling forces an additional bin
to be added; presumably, it's better to have too many rather than too few
bins -- for example, if the dx was deliberately given such that the xmax
is not at an integer bin boundary... If you use exact values for bin
bounds and increment, then there will be no problem.

[end developer's comments]

--
P.J. Hinton
User Interface Programmer                         paulh at wolfram.com
Wolfram Research, Inc.



  • Prev by Date: Re: Jlink/ReadList
  • Next by Date: Re: creating adjacency matrices
  • Previous by thread: Error in BinCounts function?
  • Next by thread: A symbol for Floor