Question: I have a list of Vector3, each with x,y,z values.

```
List<Vector3> list = new List<Vector3>();

```

I would like to iterate through this list, and find the average and create a vector from it:

resultant vector: 

```
averageVector.X = average of all the x values;
averageVector.Y= average of all the y values;
averageVector.Z = average of all the z values;

return averageVector;

```

I'm trying to create a function for this, and would love your help!

Answer: 
You can use linq [`Enumerable.Average`](https://msdn.microsoft.com/en-us/library/system.linq.enumerable.average(v=vs.90).aspx) to achive that

```
var newVector = new Vector3(
        list.Average(x=>x.X),
        list.Average(x=>x.Y),
        list.Average(x=>x.Z));

```

`list.Average(x=>x.Z)` will return average value of `Z` from all elements from `list`
A modern code way to solve this is using a Unity `Bounds` axis-aligned bounding box.

Code looks like this:

```
var bounds = new Bounds(Vector3.zero, Vector3.zero);
list.ForEach(v => bounds.Encapsulate(v));
return bounds.center;

```