## How to calculate the median of each 7 numbers out of a list of 1800

Dec 1, 2010 at 10:27pm

# How to calculate the median of each 7 numbers out of a list of 1800

I have a sensor that updates every 2 seconds. That means I have 30 reads/minute, and 1800 reads/hour. For viewing the reads I wanted to use a multislider which is limited to 256 bars, but anyways, 1800 bars would’ve been too much!

So I figure that 1800 reads / 256 bars = ~7 reads per bar (7.03125 to be more exact)

I wanted to calculate the median of each series of 7 reads but that would be 256 calculations and with something like [zl slice] and [zl median] I realize it would be too much!

Does anybody know of a simpler solution?
Thank you

PS: I also thought about reducing the original number of reads but that would beat the purpose as I really want to take into consideration each and every one of the reads.

#53660
Dec 1, 2010 at 11:41pm

Why not something like:

[zl iter 7] -> [zl median] -> [zl group 256]

I assume you mean in your post that you are concerned that your solution would be too much patching, rather than too much to calculate, as I don’t think that will be a particularly big issue.

The above assumes that you only calculate once every hour from the full list of 1800 values. However, you could modify it to give you a running output.

A.

#192939
Dec 2, 2010 at 1:26am

as they come in: zl group 7, zl median, output the answer to your multislider with the set \$1 \$2 message (with a counter to track the indices of course).

If you do them all at once, the zl iter 7–>zl median would be the best bet I think.

#192940

You must be logged in to reply to this topic.