Re: Aggregates: Largest Groups

From: David Fetter <david_at_fetter.org>
Date: Mon, 22 Mar 2010 16:48:16 -0500
Message-ID: <4oqdneNxef09eDrWnZ2dnUVZ_uOdnZ2d_at_speakeasy.net>



Gene Wirchenko <genew_at_ocis.net> wrote:
> On Mon, 22 Mar 2010 16:12:50 -0500, david_at_fetter.org (David Fetter)
> wrote:
> 

>>Gene Wirchenko <genew_at_ocis.net> wrote:
>>> On Mon, 22 Mar 2010 15:42:09 -0500, david_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 <david_at_fetter.org> http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter      XMPP: david.fetter_at_gmail.com

To the extent that we overreact, we proffer the terrorists the
greatest tribute.
                                High Court Judge Michael Kirby
Received on Mon Mar 22 2010 - 16:48:16 CDT

Original text of this message