[chronojump] ForceSensor: Fixed bug in cvRMSSD calculation
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] ForceSensor: Fixed bug in cvRMSSD calculation
- Date: Fri, 5 Feb 2021 13:57:10 +0000 (UTC)
commit 8ae5a3d05000066815ce3ff55c5ef6af760e8957
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Feb 5 14:56:30 2021 +0100
ForceSensor: Fixed bug in cvRMSSD calculation
src/forceSensor.cs | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/src/forceSensor.cs b/src/forceSensor.cs
index 1ba2a3dd..dd57059b 100644
--- a/src/forceSensor.cs
+++ b/src/forceSensor.cs
@@ -958,7 +958,7 @@ public class ForceSensorCapturePoints
double elapsedSeconds = times[countB]/1000000.0 - times[countA]/1000000.0;
return sum * UtilAll.DivideSafe(elapsedSeconds, samples);
}
-
+
public void GetVariabilityAndAccuracy(int countA, int countB, int feedbackF, out double variability,
out double feedbackDifference, bool cvRMSSD)
{
if(countA == countB)
@@ -983,18 +983,22 @@ public class ForceSensorCapturePoints
//feedbackDifference = Math.Abs(feedbackF - avg);
double sum = 0;
for(int i = countA; i <= countB; i ++)
+ {
sum += Math.Abs(forces[i]-feedbackF);
+ }
feedbackDifference = UtilAll.DivideSafe(sum, numSamples);
}
private double getVariabilityCVRMSSD (int countA, int countB, int numSamples)
{
- //Σ(x_i - x_{i+1})^2 /(n-1) )
+ //Σ(x_i - x_{i+1})^2 /(n-1)) //note pow should be inside the summation
double sum = 0;
for(int i = countA; i < countB; i ++)
- sum += forces[i] - forces[i+1];
+ {
+ sum += Math.Pow(forces[i] - forces[i+1], 2);
+ }
- return UtilAll.DivideSafe(Math.Pow(sum, 2), numSamples -1);
+ return UtilAll.DivideSafe(sum, numSamples -1);
}
private double getVariabilityOldMethod (int countA, int countB, int numSamples)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]