I have a list of objects of the same type that each has a property that is an array of floats. Taking this list as input, what is the easiest way to return a new array that is the average of the arrays in the list?
The input objects look like this:
Class MyDatas
{
float [] DataValues;
}
...
List<MyDatas> InputList;
float [] result;
The DataValues arrays will be guaranteed to have the same length. Each element of the result array will be the average of the corresponding elements in the array of each member of the list. For example: result[0] = (InputList[0].DataValues[0] + InputList[1].DataValues[0] + ... ) / InputList.Count
Of course I could brute force this with a foreach inside a for loop and then another for loop after that but it seems to me this should be doable with one or two lines of LINQ. Any advice?