[chronojump] Written test to check if rmssd matches R psych package



commit 82841d4447c0f75f41454733ae9b34637eebba22
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed May 5 13:29:37 2021 +0200

    Written test to check if rmssd matches R psych package

 src/forceSensor.cs         | 22 ++++++++++++++++++++++
 src/gui/app1/chronojump.cs |  3 +++
 2 files changed, 25 insertions(+)
---
diff --git a/src/forceSensor.cs b/src/forceSensor.cs
index b2a58485..c2cabf52 100644
--- a/src/forceSensor.cs
+++ b/src/forceSensor.cs
@@ -1160,6 +1160,28 @@ public class ForceSensorCapturePoints
                return UtilAll.DivideSafe(sum, numSamples);
        }
 
+       public static void TestVariabilityCVRMSSD()
+       {
+               /*
+                  R psych test:
+                  library("psych")
+                  > x=c(21, 45, 75, 54, 5.5, 545.5, 44, 17, 8, -15, -12.8)
+                  > rmssd(x,group=NULL, lag=1, na.rm=TRUE)
+                  [1] 234.2467
+               */
+
+               ForceSensorCapturePoints fscp = new ForceSensorCapturePoints(
+                               ForceSensorCapturePoints.GraphTypes.FORCESIGNAL, 300, 300, 10);
+               List <double> nums = new List<double> {21, 45, 75, 54, 5.5, 545.5, 44, 17, 8, -15, -12.8};
+               for (int i = 0; i < nums.Count; i ++)
+                       fscp.Add(i+1, nums[i]);
+
+               double variability = 0;
+               double feedbackDiff = 0;
+               fscp.GetVariabilityAndAccuracy(0, nums.Count -1, 20, out variability, out feedbackDiff, true);
+               LogB.Information("cvRMSSD: " + variability);
+       }
+
        public int MarginLeft
        {
                get { return marginLeft; }
diff --git a/src/gui/app1/chronojump.cs b/src/gui/app1/chronojump.cs
index 674b1be5..21c79d66 100644
--- a/src/gui/app1/chronojump.cs
+++ b/src/gui/app1/chronojump.cs
@@ -936,6 +936,9 @@ public partial class ChronoJumpWindow
                */
 
                //Util.TestSortDoublesListstring();
+
+               //Test ForceSensor GetVariabilityAndAccuracy: getVariabilityCVRMSSD
+               ForceSensorCapturePoints.TestVariabilityCVRMSSD();
        }
 
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]