MathGroup Archive 2005

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

Search the Archive

Re: BinCounts

  • To: mathgroup at smc.vnet.net
  • Subject: [mg60931] Re: [mg60918] BinCounts
  • From: "Carl K. Woll" <carl at woll2woll.com>
  • Date: Tue, 4 Oct 2005 01:24:58 -0400 (EDT)
  • References: <200510030806.EAA00260@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Alberto Verga wrote:
> Why does BinCounts[] give lists with unpredictable Dimensions[]?
>
> With[{n = 205}, ll = RandomArray[NormalDistribution[0, 1], {n}];
> Dimensions[BinCounts[ll, {Min[ll], Max[ll], (Max[ll] - Min[ll])/n}]]]
>
>
>
> You may try different values of n (or the same n and different samples of
> the random numbers), and verify that the lenght of the list depends on the
> random realization: somtimes you get n, somtimes n+1.
>

You get different results because of numerical error associated with using 
inexact numbers like machine numbers. Instead, use exact arithmetic or add a 
fudge factor. Assuming you want to get n bins, the following approach will 
always do so for reasonable data:

BinCounts[ll, {Min[ll],Max[ll],(Max[ll]-Min[ll])/n + $MachineEpsilon}]

Alternatively, you could use Rationalize by replacing Min[ll] (and Max[ll]) 
with Rationalize[Min[ll],0] etc.

> Alberto Verga
>
>
>      Alberto Verga
>
>      IRPHE - Université de Provence
>
>      49, rue F. Joliot-Curie, BP 146,
>
>      13384 Marseille, France
>
>
>
>

Carl Woll
Wolfram Research 




  • References:
    • BinCounts
      • From: Alberto Verga <Alberto.Verga@laposte.net>
  • Prev by Date: Partition(divid string to substring
  • Next by Date: Re: Help with output form?
  • Previous by thread: BinCounts
  • Next by thread: Re: BinCounts