calculating the mean

This is a discussion on calculating the mean within the C Programming forums, part of the General Programming Boards category; I need an algorithm to calculate the mean of a list of values. The values are some CPU times, some ...

calculating the mean

I need an algorithm to calculate the mean of a list of values. The values are some CPU times, some of these values are very different from the rest. I want to calculate the mean without these values. Anyone knows about an algorithm to make this??

I mean for example that all the values are around 0.0001 and a few 0.0008 for example or bigger. I think I'm going to calculate the variance for each value and try to mantain the variance very close to 0. Thanks for the answers!

Well following from what grumpy said, define the bounds for which the values become outliers based on the greatest and least of the values that are not outliers.

Suppose we have a list of values:

2,50,75,98,101,467

We can see that 2 and 467 are outliers

So we can estimate a range for which we can expect outliers to be in.

Suppose we say, that values greater than the double of the greatest number not an outlier, which means 202 is the upper bound and a value that is half of the least number not an outlier which is anything less than 25.

This is ofcourse dependent on what the values really mean, here it's just arbitrary, I don't know what CPU times look like exactly, but I'm guessing they are small, so you must take a close look at what values are generated and run a series of tests to see the different values you do get and based on that estimate what the outliers could be.

There probably is a much better way to do this if you look at the equations for standard deviation and some equations off statistical maths, they aren't very hard to understand, I don't know about implementing them though

I need an algorithm to calculate the mean of a list of values. The values are some CPU times, some of these values are very different from the rest. I want to calculate the mean without these values. Anyone knows about an algorithm to make this??

Thank you.

Can I ask why you want to compute the mean of a bunch of CPU times? It's a common fallacy to think that you should run a task N times and then average the times -- what you should really do is simply take the smallest.