Re: Counting Runs
- To: mathgroup at smc.vnet.net
- Subject: [mg51928] Re: [mg51890] Counting Runs
- From: DrBob <drbob at bigfoot.com>
- Date: Fri, 5 Nov 2004 02:17:29 -0500 (EST)
- References: <200411040650.BAA18131@smc.vnet.net>
- Reply-to: drbob at bigfoot.com
- Sender: owner-wri-mathgroup at wolfram.com
data={1,1,1,-1,1,1,1,1,1,-1,-1,-1,-1,1}; Count[Split@data,{#,___},{1}]&/@Union@data {#,Count[Split@data,{#,___},{1}]}&/@Union@data {2,3} {{-1,2},{1,3}} Bobby On Thu, 4 Nov 2004 01:50:22 -0500 (EST), Gregory Lypny <gregory.lypny at videotron.ca> wrote: > > > Looking for an elegant way to count runs to numbers in a series. > Suppose I have a list of ones and negative ones such as > v={1,1,1,-1,1,1,1,1,1,-1,-1,-1,-1,1}. > I'd like to create a function that counts the number of runs of 1s and > -1s, which in this case is 3 and 2. > > Greg > > > > -- DrBob at bigfoot.com www.eclecticdreams.net
- References:
- Counting Runs
- From: Gregory Lypny <gregory.lypny@videotron.ca>
- Counting Runs