gpsd-dev
[Top][All Lists]

## [gpsd-dev] [PATCH 2/2] Remove code that calculates leastsquares fit.

 From: Sanjeev Gupta Subject: [gpsd-dev] [PATCH 2/2] Remove code that calculates leastsquares fit. Date: Sat, 9 May 2015 10:41:25 +0800

```See previous (related) patch for rationale.
---
leapsecond.py | 25 -------------------------
1 file changed, 25 deletions(-)

diff --git a/leapsecond.py b/leapsecond.py
index 2de3a2e..05018e6 100755
--- a/leapsecond.py
+++ b/leapsecond.py
@@ -254,31 +254,6 @@ def conditional_leapsecond_fetch(outfile, timeout):
return True

-def leastsquares(tuples):
-    "Generate coefficients for a least-squares fit to the specified data."
-    sum_x = 0
-    sum_y = 0
-    sum_xx = 0
-    sum_xy = 0
-    for (x, y) in tuples:
-        sum_x = sum_x + x
-        sum_y = sum_y + y
-        xx = math.pow(x, 2)
-        sum_xx = sum_xx + xx
-        xy = x * y
-        sum_xy = sum_xy + xy
-    n = len(tuples)
-    c = (-sum_x * sum_xy + sum_xx * sum_y) / (n * sum_xx - sum_x * sum_x)
-    b = (-sum_x * sum_y + n * sum_xy) / (n * sum_xx - sum_x * sum_x)
-    # y = b * x + c
-    maxerr = 0
-    for (x, y) in tuples:
-        err = y - (x * b + c)
-        if err > maxerr:
-            maxerr = err
-    return (b, c, maxerr)
-
-
def iso_to_unix(tv):
"Local Unix time to iso date."
return calendar.timegm(time.strptime(tv, "%Y-%m-%dT%H:%M:%S"))
--
2.1.4

```