Round to the Nearest Half
[math]::Round($number * 2, [MidpointRounding]::AwayFromZero) / 2
Minimum value from list of numbers
$sum = $NumberArray | Measure-Object -Minimum $sum.Minimum
Maximun value from list of numbers
$sum = $NumberArray | Measure-Object -Maximum $sum.Maximum
Average a list of numbers
$sum = $NumberArray | Measure-Object -Average $sum.Average
Find the Mode Value
# Get the number of occurrences for each number $numberCount = $NumberArray | Group-Object | Sort-Object -Descending count # check that it is possble to calculate a mode if(@($numberCount | Select-Object Count -Unique).Count -gt 1){ # Get the count for the numbers with the most occurrences $topCount = ($numberCount | Select-Object -First 1).Count # Get the most frequently occurring values...
Find the Median Value
# sort array $NumberArray = $NumberArray | Sort-Object if ($NumberArray.count%2) { # if odd $medianvalue = $NumberArray[[math]::Floor($NumberArray.count/2)] } else { # if even $MedianValue = ($NumberArray[$NumberArray.Count/2],$NumberArray[$NumberArray.count/2-1] | Measure-Object -Average).average } $MedianValue