Exemple #1
0
        /// <summary>
        ///   Returns the median value of the Vector.
        /// </summary>
        /// <param name="source">Vector.</param>
        /// <returns>Double.</returns>
        public static double Median(this Vector source)
        {
            var v = source.OrderBy(o => o).ToArray();

            return((v[(int)System.Math.Floor((v.Length - 1.0) / 2.0)] * (source.Length % 2)
                    + v[(int)System.Math.Floor(v.Length / 2.0)]) / 2.0);
        }