csharp 来自http://stackoverflow.com/questions/2714639/weighted-average-with-linq

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp 来自http://stackoverflow.com/questions/2714639/weighted-average-with-linq相关的知识,希望对你有一定的参考价值。

public static double WeightedAverage<T>(this IEnumerable<T> records, Func<T, double> value, Func<T, double> weight)
    {
        double weightedValueSum = records.Sum(x => value(x) * weight(x));
        double weightSum = records.Sum(x => weight(x));

        if (weightSum != 0)
            return weightedValueSum / weightSum;
        else
            throw new DivideByZeroException("Your message here");
    }

以上是关于csharp 来自http://stackoverflow.com/questions/2714639/weighted-average-with-linq的主要内容,如果未能解决你的问题,请参考以下文章

csharp 来自csvj的getFrameworkVersion在tfvc上

csharp 来自http://www.codemag.com/Article/1312081

csharp 来自http://www.codemag.com/Article/1312081

csharp 来自http://www.codemag.com/Article/1312081

csharp 来自http://www.codemag.com/Article/1312081

csharp HMACSHA256来自http://ideone.com/JdpeL