[chronojump] UtilAll.GetAverage() to get AVG of list of doubles
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] UtilAll.GetAverage() to get AVG of list of doubles
- Date: Fri, 15 Oct 2021 11:46:14 +0000 (UTC)
commit aa4a95567c67b40a1ea59309f3c27e7add56e173
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Oct 15 13:44:31 2021 +0200
UtilAll.GetAverage() to get AVG of list of doubles
src/util.cs | 8 ++++++++
1 file changed, 8 insertions(+)
---
diff --git a/src/util.cs b/src/util.cs
index 2ba769268..e1d526f95 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -203,6 +203,14 @@ public class Util
return min ;
}
+ public static double GetAverage (List<double> values)
+ {
+ double sum = 0;
+ foreach(double d in values)
+ sum += d;
+
+ return UtilAll.DivideSafe(sum, values.Count);
+ }
public static double GetAverage (string values)
{
if(values.Length == 0)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]