Re: Reconciling BinCounts and RangeCounts
- To: mathgroup at smc.vnet.net
- Subject: [mg68028] Re: [mg68014] Reconciling BinCounts and RangeCounts
- From: János <janos.lobb at yale.edu>
- Date: Fri, 21 Jul 2006 05:37:13 -0400 (EDT)
- References: <200607201004.GAA09880@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
On Jul 20, 2006, at 6:04 AM, Gregory Lypny wrote:
>
> Hello Everyone,
>
> I get a discrepancy between the results of BinCounts and RangeCounts
> and can confirm only that RangeCounts is, in fact, counting the
> number of instances where a number is at least as big as the lower
> cut-off and less than the upper cut-off. Not so for BinCounts, which
> leads me to believe that it is buggy or, more likely, I am.
>
> I have a vector, x, with 7320 observations of real numbers in the
> range .06 to .14 with up to seven decimal places. Here's what I get
> if I use bins or cut-offs of .01.
>
> First with BinCounts
> BinCounts[x, {.06, .14, .01}]
> {103, 333, 802, 1266, 997, 662, 611, 2265, 281}
>
> Now with RangeCounts
> RangeCounts[x, Range[.07, .14, .01]]
> {103, 333, 797, 1270, 997, 663, 611, 2265, 281}
>
> Notice that elements 3, 4, and 6 of the results differ. So I tried
> to check what was going on by using Select and was able to confirm
> all of the RangeCounts elements. For example, the third element of
> the RangeCounts results, 797, can be confirmed by using
>
> Length[Select[x, .08 =B2 # < .09 &]] >>>> returns 797
>
> However, the third element of the BinCounts results, 802, can be
> obtained only if I include the upper bound, .09, in the count as
>
> Length[Select[x, .08 =B2 # =B2 .09 &]] >>>>> returns 802,
>
> which of course makes no sense because we need a strong inequality
> for one of them. But it gets worse. When I go on to check elements
> 4 and 6 of BinCounts, there is no combination of weak or strong
> inequalities that will give me the results 1266 and 662.
>
> Can anyone shed any light on this? In the meantime, I think it
> safest to use RangeCounts.
>
> Regards,
>
> Gregory=
>
It probably relates that RangeCount counts elements in open intervals:
'list the number of elements in the data a, a, ? that lie between
successive cutoffs a'
BinCount relates to half closed intervals :
'list the number of elements in the data a, a, ? that lie in bins
from xmin to xmax in steps of dx'
/Excuse my copy and paste English/
János
- References:
- Reconciling BinCounts and RangeCounts
- From: Gregory Lypny <gregory.lypny@videotron.ca>
- Reconciling BinCounts and RangeCounts