constantly report the median of last second flow of numbers

I’m trying to solve this problem, which looked simple to me, but I can’t solve it.
I have a flow of numbers coming at irregular intervals and I’d like to calculate the median for istance of the past 1 second. I know how to return the median value every second, but what i can’t figure out is how i can have the median not only giving me result every second, but constantly.
If something happens at a millisecond rate, I’d like to have the idea istant by istant what the last second was. And i can’t solve this problem.

I tried several obkects like [bucket] [pak] [zl median] [accum], but i can only have them reporting me the median of the (very quick) flow "every" second, not instantly (like 200 msec).

yes i’m evidently mildly dyslexic– looking at its help file it talks about mean of means, which I read as median of medians (a statistical procedure), so anyway chris’ (topher) bag approach is probably the one to use

wow, I didn’t see your last posts guys! very very nice solution [bag], I didn’t know it either, and looks like it is the best memory-efficient and simpler tool, great!
I’ll have a look at [meandev] now, but this solution Cristopher is really good for me!
So, i assume if I want to check different time spans all I have to do is to change the pipe attribute, so if I want to track 30 secs all I have to do is this:

— Pasted Max Patch, click to expand. —

Copy all of the following text. Then, in Max, select New From Clipboard.

To clarify meandev does not calculate the median ever, only means and deviations. The mean of means business is something that was probably useful at the time, but I forget what for (this is one of the oldest object in the package dating back over 5 years now I think and when I updated it more recently I just left all the old stuff in there).

I could update it to do medians some time, but no promises especially as there are some good max solutions here.

However, a word of caution:

zl will only allow up to 256 values unless you specify otherwise.

Below is my altered solution from christopher’s. This will work such that whenever something goes in or comes out of the bag the output is updated, without needing a metro 1 (which is a lot of unnecessary calculation).It also allows lists of up to 4096 values.

Alex

— Pasted Max Patch, click to expand. —

Copy all of the following text. Then, in Max, select New From Clipboard.