Re: Binning data before analysis
- To: mathgroup at smc.vnet.net
- Subject: [mg21263] Re: [mg21196] Binning data before analysis
- From: BobHanlon at aol.com
- Date: Mon, 20 Dec 1999 02:28:26 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Needs["Statistics`DataManipulation`"];
Based on your example and the fact that you listed the cutoff list
as if it were an iterator, it appears that you want to use BinLists
vice RangeLists.
nbrElements = 1000;
data = Table[{Random[Integer, {0, 10}], Random[]}, {nbrElements}];
eps = $MachineEpsilon;
BinLists[data, {0 - eps, 10, 2}, {0, 1, 1}];
Transpose[RangeLists[data, Table[k(1 + eps), {k, 2, 8, 2}], {0, 1}]][[2]];
(Flatten[%%, 1] == %) && (Length[Flatten[%]] == 2*nbrElements)
True
There appears to be some slight problem with including end values
as well as a difference between BinLists and RangeLists as to how
their bin boundary values are handled (inclusive versus exclusive).
To compensate for this, I have used slight offsets (eps).
Bob Hanlon
In a message dated 12/17/1999 3:17:30 AM, noname at noname.com writes:
>I'm looking for a simple way of binning multivariate data before
>analysis.With a vector of data points, this is easy to do with RangeLists
>or
>something similar from the Statistics`DataManipulation package. e.g.:
>
>In[1]:=
> data = Table[Random[Integer, {0, 10}], {10}];
>
>Out[1]:=
> {0, 1, 5, 5, 3, 6, 1, 1, 1, 2}
>
>In[2]:=
> RangeLists[d, {0, 6, 2}]
>
>Out[2]:=
> {{}, {0, 1, 1, 1, 1}, {5, 5, 3, 2}, {6}}
>
>But what I actually want to do is bin a set of data consisting of
>{{timeOfPresentationOfStimulus, Response1, Response2, ...}
>
>so that I can get the Mean responses for the data when binned by
>timeOfPresentation into, say, 10 millisecond bins.
>Some neat permutation trick on the indices ought to do the job, but I can't
>see it.
>