I recently published my Measure-ScriptBlock function, where you can set how many times you want to take measurements of your code block, and get the mean value (average) calculated before output. That is all and well, but running it I could see that sometimes there would be some measurements that would spike and make the mean value higher than it really “should” be.
I started thinking about how it would be neat if I could calculate the trimmed mean instead. When calculating a trimmed mean, you remove (trim) a certain portion at the beginning and end of your (sorted) set, and then calculate the mean of the remaining values.
The idea is to use this function in my Measure-ScriptBlock function, but I thought I’d release it on it’s own as well. Might be others that can find it useful as well.