/// <summary> /// Calculates the average of the elements of a vector. /// </summary> /// <param name="Vector">Vector</param> /// <param name="Node">Node performing evaluation.</param> /// <returns>Average of elements.</returns> public static IElement EvaluateAverage(IVector Vector, ScriptNode Node) { IElement Result = Vectors.Sum.EvaluateSum(Vector, Node); int n = Vector.Dimension; if (Result is null) { return(ObjectValue.Null); } else { IRingElement Avg; if (Result is IRingElement RE && !((Avg = RE.MultiplyRight(new DoubleNumber(1.0 / n))) is null)) { return(Avg); }