Reconciling BinCounts and RangeCounts
- To: mathgroup at smc.vnet.net
- Subject: [mg68014] Reconciling BinCounts and RangeCounts
- From: Gregory Lypny <gregory.lypny at videotron.ca>
- Date: Thu, 20 Jul 2006 06:04:54 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
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=
- Follow-Ups:
- Re: Reconciling BinCounts and RangeCounts
- From: János <janos.lobb@yale.edu>
- Re: Reconciling BinCounts and RangeCounts