# Time 1, Exercise 2: accuracy, precision and stability of three clocks # Offsets (clock minus true time, in seconds) read at midnight on 8 days. # For each clock find the mean daily rate (accuracy) and the spread of the # daily changes (stability). Which clock would you trust? import statistics clocks = { "A": [0.0, 2.1, 3.9, 6.0, 8.1, 9.9, 12.0, 14.1], "B": [0.0, 0.4, -0.3, 0.2, -0.5, 0.1, 0.5, -0.2], "C": [0, 3, 5, 9, 11, 16, 17, 22], } for name, offsets in clocks.items(): daily = [round(b - a, 2) for a, b in zip(offsets, offsets[1:])] rate = (offsets[-1] - offsets[0]) / (len(offsets) - 1) spread = statistics.stdev(daily) print(name, "daily changes", daily) print(name, "mean rate", round(rate, 3), "s/day; spread", round(spread, 3), "s") # Output when run: # A daily changes [2.1, 1.8, 2.1, 2.1, 1.8, 2.1, 2.1] # A mean rate 2.014 s/day; spread 0.146 s # B daily changes [0.4, -0.7, 0.5, -0.7, 0.6, 0.4, -0.7] # B mean rate -0.029 s/day; spread 0.632 s # C daily changes [3, 2, 4, 2, 5, 1, 5] # C mean rate 3.143 s/day; spread 1.574 s # # Reading the output: A gains about 2 s a day, so it is inaccurate, but its # rate hardly changes (spread 0.15 s): it is very stable. Because the rate is # steady you can measure it once and correct for it, so A is the clock you # can improve. B has almost no average drift (accurate over the week) but its # daily changes bounce about by 0.6 s: it is the least stable of the first two # and you cannot predict tomorrow's error. C is poor on both counts, and it # is also read only to whole seconds, which limits its resolution. # Over a year, A's error would be about 2.014 x 365 = 735 s, roughly 12 minutes.