static double[] Rank(IEnumerable <double> series) { if (series == null) { return(new double[0]); } // WARNING: do not try to cast series to an array and use it directly, // as we need to sort it (inplace operation) var data = series.ToArray(); return(ArrayStatistics.RanksInplace(data, RankDefinition.Average)); }
/// <summary> /// Evaluates the rank of each entry of the provided samples. /// The rank definition can be specificed to be compatible /// with an existing system. /// </summary> /// <param name="data">The data sample sequence.</param> /// <param name="definition">Rank definition, to choose how ties should be handled and what product/definition it should be consistent with</param> public static double[] Ranks(this IEnumerable <double> data, RankDefinition definition = RankDefinition.Default) { var array = data.ToArray(); return(ArrayStatistics.RanksInplace(array, definition)); }