ChensHelpers
Chen.Helpers.MathHelpers.Arithmetic
Arithmetic.Average(int[], Func<int,int>) Method
Computes for the average of the numbers in the array. Preprocessing each item is possible before they are computed by providing the logic.
e.g. Average(new int[] { 2, -4, 2 }, item => Mathf.Max(2, item)) will yield a result of 2.
public static float Average(this int[] numbers, System.Func<int,int> preProcess=null);
Parameters
numbers
System.Int32[]
Array of numbers
preProcess
System.Func<System.Int32,System.Int32>
Preprocessor code
Returns
System.Single
Average of the values in the array
Exceptions
System.DivideByZeroException
Raised when the array length is 0 when division is performed.