# Re: Aggregates: Largest Groups

From: Nilone <reaanb_at_gmail.com>
Date: Tue, 23 Mar 2010 01:28:09 -0700 (PDT)

On Mar 22, 11:48 pm, da..._at_fetter.org (David Fetter) wrote:
> Gene Wirchenko <ge..._at_ocis.net> wrote:
> > On Mon, 22 Mar 2010 16:12:50 -0500, da..._at_fetter.org (David Fetter)
> > wrote:
>
> >>Gene Wirchenko <ge..._at_ocis.net> wrote:
> >>> On Mon, 22 Mar 2010 15:42:09 -0500, da..._at_fetter.org (David Fetter)
> >>> wrote:
>
> >>>>Let's say I have a traffic monitoring system.  The stream of data
> >>>>coming in records a timestamp and a speed for each vehicle.
>
> >>>>I'd like to know what all the groups of vehicles larger than X whose
> >>>>with average speed over Y is.
>
> >>>>Any ideas how to approach this?
>
> >>>     First, define your terms.  What is a group?  What does "larger
> >>> than X" mean?  (Size of vehicle?  Number of vehicles in the group?)
>
> >>Number of vehicles in the group.
>
> >     And what is a group?
>
> Those vehicles, grouped in time, whose average speed is >= Y.
>
> Let's say we're looking for groups of 20 or more vehicles whose
> average speed is >= 175 kph.
>
> The first 20 vehicles pass by at 200 kph, then another 20 pass at 100,
> each at distinct times.
>
> When vehicle 6 of the slower bunch passes, the average speed of cars
> up until now is (20*200+6*100)/26 or ~176.92 kph.  Vehicle 7 passes,
> and the average is now ~174.07, which is under 175, so the first group
> has 26 vehicles in it, and we're now looking to start the next group.
>
> Cheers,
> David.
> --
> David Fetter <da..._at_fetter.org>http://fetter.org/
> Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
> Skype: davidfetter      XMPP: david.fet..._at_gmail.com
>
> To the extent that we overreact, we proffer the terrorists the
> greatest tribute.
>                                 High Court Judge Michael Kirby

Perhaps a variation of Kadane's algorithm? Received on Tue Mar 23 2010 - 09:28:09 CET

Original text of this message