ChensHelpers
Chen.Helpers.MathHelpers.Arithmetic
Arithmetic.Average(float[], Func<float,float>) 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 float[] { 2f, -4f, 2f }, item => Mathf.Max(2f, item)) will yield a result of 2f.
public static float Average(this float[] numbers, System.Func<float,float> preProcess=null);
Parameters
numbers
System.Single[]
Array of numbers
preProcess
System.Func<System.Single,System.Single>
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.