marco.shaw Posted November 29, 2006 Report Share Posted November 29, 2006 An average are not always the best statistical value when dealing with a set of numbers. Here's a way to determine the median of some values: $array=(gc ($args)|foreach{[int]$_}|sort) if($array.count%2 -eq 0) {write-host median: (($array[($array.count/2)-1]+$array[$array.count/2])/2)} else{write-host median: $array[($array.count/2)-0.5]} The file containing the number to get the median from is provided as an argument when calling the script. The input file should be of the format: 10 20 300 30 etc. (I haven't quite figured out how to handle the line wrapping with posts here.) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.