Implement weighted average
MODIFY
WalletWasabi/Extensions/LinqExtensions.cs
WalletWasabi/Extensions/LinqExtensions.cs
@@ -208,4 +208,9 @@ public static class LinqExtensions
}
}
}
+
+ public static double WeightedAverage<T>(this IEnumerable<T> source, Func<T, double> value, Func<T, double> weight)
+ {
+ return source.Select(x => value(x) * weight(x)).Sum() / source.Select(weight).Sum();
+ }
}

Implement weighted average