At 1:58 AM +0200 2003/09/21, ard.jonker@xxxxxxxxx wrote: > Brad, does that mean that you have a variable number of elements in > your list? In that case, maybe the modal number would be more handy. If you take one sample per second, then the number of elements in the array to be considered would depend on how many seconds that sample was taken over. If you use a queue and only record the last five minutes worth of samples (since that's where the chart rolls off the end), then you have an upper bound on the size of the array. However, you don't want to use mode -- it's too easy to get into multi-modal distributions, or where the mode is way off from the median and the mean. Mode is only of interest once you have the other measures and you're trying to understand where all the peaks are and why. > The number of the bucket with the highest content is taken as the > modal value. I guess you could call this 'histogram maximum' too. No > statistics and no dynamic memory allocation involved ;-) No dynamic memory allocation is necessary for calculating median or mean, either. Just statically allocate an array that is the proper size for five minutes worth of samples times however many samples you take per minute, and then keep a counter showing where the last entry is -- use it like a ring buffer, and roll-over the counter when you reach the end of the array. -- Brad Knowles, <brad.knowles@xxxxxxxxx> "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin, Historical Review of Pennsylvania. GCS/IT d+(-) s:+(++)>: a C++(+++)$ UMBSHI++++$ P+>++ L+ !E-(---) W+++(--) N+ !w--- O- M++ V PS++(+++) PE- Y+(++) PGP>+++ t+(+++) 5++(+++) X++(+++) R+(+++) tv+(+++) b+(++++) DI+(++++) D+(++) G+(++++) e++>++++ h--- r---(+++)* z(+++)