From 3b46aa856fbcf1f312e272206aa04ec5171126fb Mon Sep 17 00:00:00 2001 From: Amber Date: Sat, 21 Jan 2023 20:59:23 +0300 Subject: [PATCH] Fix weight calculation --- BecquerelMonitor/Utils/CalibrationSolver.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/BecquerelMonitor/Utils/CalibrationSolver.cs b/BecquerelMonitor/Utils/CalibrationSolver.cs index d26a10f..1a1b324 100644 --- a/BecquerelMonitor/Utils/CalibrationSolver.cs +++ b/BecquerelMonitor/Utils/CalibrationSolver.cs @@ -60,7 +60,7 @@ public static double[] SolveWeighted (List points, int Polynom double[] dense_vector = new double[points.Count]; double[,] dense_weight = new double[points.Count, points.Count]; - int max_count = 1; + double max_count = 1.0; for (int i = 0; i < points.Count; i++) { if (points[i].Count > max_count) @@ -68,6 +68,7 @@ public static double[] SolveWeighted (List points, int Polynom max_count = points[i].Count; } } + max_count = Math.Sqrt(max_count); for (int i = 0; i < points.Count; i++) { @@ -75,7 +76,7 @@ public static double[] SolveWeighted (List points, int Polynom { if (i == j) { - dense_weight[i, j] = (double)points[i].Count / (double)max_count; + dense_weight[i, j] = Math.Sqrt((double)points[i].Count) / (double)max_count; } else {