altoslib: Fix time series filter window computation
authorKeith Packard <keithp@keithp.com>
Thu, 12 Oct 2017 07:30:23 +0000 (00:30 -0700)
committerKeith Packard <keithp@keithp.com>
Thu, 12 Oct 2017 07:30:23 +0000 (00:30 -0700)
Small floating point rounding errors could lead to NaNs.

Signed-off-by: Keith Packard <keithp@keithp.com>
altoslib/AltosTimeSeries.java

index 7208c176d1450678e324a29d8a591d10279d5668..c6a780a31a6e41023a8ceaccb5799b85ad287b71 100644 (file)
@@ -294,7 +294,7 @@ public class AltosTimeSeries implements Iterable<AltosTimeValue>, Comparable<Alt
                double alpha = m / 2;
                double t = (n - alpha) / alpha;
 
-               if (t > 1)
+               if (t > 1 || t < -1)
                        t = 1;
                double k = i0 (beta * Math.sqrt (1 - t*t)) / i0(beta);
                return k;