[chronojump] InterpolateSignal can Test also signals with negative values



commit f29fd93aa9f3e4f752e6124d8a82b3e1336725f1
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed May 26 10:01:23 2021 +0200

    InterpolateSignal can Test also signals with negative values

 src/gui/app1/chronojump.cs |  2 +-
 src/utilMath.cs            | 16 ++++++++++++----
 2 files changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/src/gui/app1/chronojump.cs b/src/gui/app1/chronojump.cs
index 20b1d3736..c91335a82 100644
--- a/src/gui/app1/chronojump.cs
+++ b/src/gui/app1/chronojump.cs
@@ -941,7 +941,7 @@ public partial class ChronoJumpWindow
                ForceSensorCapturePoints.TestVariabilityCVRMSSD();
 
                //InterpolateSignal.TestInterpolateBetween();
-               //InterpolateSignal.TestCosineAndCubicInterpolate();
+               //InterpolateSignal.TestCosineAndCubicInterpolate(true);
        }
 
 
diff --git a/src/utilMath.cs b/src/utilMath.cs
index dbfbbf82a..fcb88d22d 100644
--- a/src/utilMath.cs
+++ b/src/utilMath.cs
@@ -493,13 +493,21 @@ public class InterpolateSignal
                return(a0*mu*mu2+a1*mu2+a2*mu+a3);
        }
 
-       public static void TestCosineAndCubicInterpolate()
+       public static void TestCosineAndCubicInterpolate(bool onlyPositives)
        {
                Random random = new Random();
                List<PointF> l = new List<PointF>();
 
                for(int i = 0; i < 100; i += 10)
-                       l.Add(new PointF(i, random.NextDouble() * 10));
+               {
+                       if(onlyPositives) {
+                               l.Add(new PointF(i, random.NextDouble() * 10)); // 0-10
+                       } else {
+                               //negatives & positives (0-10)
+                               //https://stackoverflow.com/a/1064907
+                               l.Add(new PointF(i, random.NextDouble() * (10 - -10) + -10));
+                       }
+               }
 
                InterpolateSignal fsp = new InterpolateSignal(l);
 
@@ -590,10 +598,10 @@ public class InterpolateSignal
                /*
                   test it with R:
                   d=read.csv2("/tmp/chronojump_testinterpolate_COSINE.csv")
-                  plot(d$X, d$Y, col=d$color, cex=d$cex, type="b", xlim=c(0,90), ylim=c(0,10))
+                  plot(d$X, d$Y, col=d$color, cex=d$cex, type="b")
                   par(new=T)
                   d=read.csv2("/tmp/chronojump_testinterpolate_CUBIC.csv")
-                  plot(d$X, d$Y, col=d$color, cex=d$cex, type="b", xlim=c(0,90), ylim=c(0,10))
+                  plot(d$X, d$Y, col=d$color, cex=d$cex, type="b")
                 */
        }
 


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