Part I

----- Original Message ----- 
From: "Tom Van Baak"
To: "Time Nuts"
Sent: Thursday, November 30, 2006 7:37 AM
Subject: Re: [time-nuts] Predicting clock stability from
         the various characterization methods

Ignore Allan deviation for a moment and work through the
process with me for a minute. Imagine checking the time
error of a nice quartz clock each minute.

Let's say your first phase reading, P0, is 10 us, and the
second reading a minute later, P1, is 21 us. What do
you know so far?

Well, you know the time error (also called phase error)
between your clock and your reference is a couple tens
of microseconds. That tells you how "on time" the clock
is. You now know your clock isn't perfectly on time.
Close, but not perfect. What else do you know?

With just two points, you know that your clock has drifted
in time by 11 us in a minute. Congratulations, you have
now determined the frequency error of the clock. It is
11 us / 1 minute = 11e-6 s / 60 s = 0.18 ppm = 1.83e-7.
A drift in time is the same thing as frequency offset, also
called frequency error. F1 = (P1 - P0) / 60 s. So your
clock is not only not perfectly on time, it is also not
keeping perfect time. Close, but not perfect.

Now, based on just those two readings, what would you
expect; what would you guess; what would you bet that
reading P2 will be?

I think you would agree that since your clock appears to
be drifting in time by 11 us per reading that P2 should be
about 32 us, right? The expected gain is P1-P0, or 11 us.
The last reading was P1=21 us, so your guess is simply
P1 + (P1 - P0) = 2 P1 - P0 = 32 us. Right?

OK, you wait a minute and P2 is 35 us. Your guess was
close. That's good. If the clock were perfectly stable, it
should have read 32 us, but it was off by a bit. Not only
is your clock off a bit in time, and off a bit in frequency,
it is also off a bit in predictability, in stability. Close, but
not perfect.

What do you know now? Well, based on points P1 and P2
the frequency error for this reading, F2 = 35-21 = 14us/min =
0.23 ppm = 2.33e-7. So you now have two frequency
readings. You can no longer boldly claim the frequency
error of your clock is exactly 1.83e-7; you are more inclined
to say it is 2e-7 because you realize both readings differ,
and are imprecise, but both close to 2e-7. You sense an
average would be a better measure.

You also know that your prediction was off by 3 us. Why?
Your prediction P2' was 32. The actual P2 was 35 . The
error in your guess, E2 = P2 - P2' is
    E2 = P2 - [ P1 + (P1 - P0) ] = P2 - 2 P1 + P0

Are you with me so far? Imagine keeping this up for a while
and making many predictions and collecting many actual
phase readings. Each new phase reading gives you a new
frequency measure; you hope they continue to average to
a nice value that you can write on your oscillator. Each
new phase reading gives you another chance to see how
well your prediction matches. You hope the errors of your
prediction stay pretty small. This time it was 3 us. Next
perhaps 2, or 4, or -3, or -1, or 5, etc. These are the small
errors in your ability to predict the phase error of the next
reading.

After a batch of N phase readings you have collected
N-1 Fi and so your average frequency error is the sum
of all Fi divided by N-1. You are also curious how confident
you are in your frequency average. You could compute
the standard deviation.

You are also curious how small your errors of prediction
are. You have collected N-2 Ei and it would be good to
compute the standard deviation of this too.

When it comes to an oscillator like this, the initial phase
error is usually no problem (you can correct for this). And
even a frequency error is not a problem (you can correct
for this in hardware or software).

What really gets you is the uncertainty in the frequency;
the jitter; the instability; the limitations of the clock in
meeting your predictions. This, you cannot correct for
and so it is a measure of how intrinsically good your
clock is.

Do you remember the square root sum of squares formula
for stdev? Take a look now at the formula for Allan Variance
or Allan Deviation. Can you see that it is just the standard
deviation of all those P2 - 2 P1 + P0 phase prediction error
terms? So Allan Deviation is not some magic formula; it's
just a regular old standard deviation formula used in a
special case.

And this is why the Allan Deviation can be used as a
predictor of time drift; by definition, it is a measure of
the expected deviation of time drift.

/tvb

See also these ADEV links, in order:

An non-technical ADEV summary from USNO:
    Clock Performance and Performance Measures
    http://tycho.usno.navy.mil/mclocks2.html

A scholarly paper on ADEV is found here:
    The Basics of Frequency Stability Analysis
    http://www.wriley.com/paper2ht.htm

This is an all-time classic:
    The Science of Timekeeping. Application Note 1289
    http://www.allanstime.com/Publications/DWA/Science_Timekeeping/
    TheScienceOfTimekeeping.pdf

This a nice write-up from NIST:
    Properties of Oscillator Signals and Measurement Methods
    http://tf.nist.gov/phase/Properties/main.htm

Some free ADEV source code:
    http://www.leapsecond.com/tools/adev1.htm

Many of my plots are made with Bill Riley's Stable32:
    http://www.wriley.com
But even if you don't need to buy his software you can
enjoy all his papers.

Part II

----- Original Message -----
From: "Tom Van Baak"
To: "Time Nuts"
Sent: Thursday, November 30, 2006 11:26 AM
Subject: Re: [time-nuts] Predicting clock stability from
         the various characterization methods

----

By the way, here's extra credit for some of you:

(1) With one point you get phase, or time error.

(2) With two points you get change in phase over time,
or frequency.

(3) With three points you get change in frequency over
time, or drift. The standard deviation of the frequency
prediction errors is called the Allan Deviation.

This is a measure of frequency stability; the better the
predicted frequency matches the actual frequency the
lower the errors. A little bit of noise or any drift causes
the errors to increase; the ADEV to increase. In the
summation you'll see terms like P2 - 2*P1 + P0. You
can see why constant phase offset or frequency offset
doesn't affect the sum.

(4) With four points you get change in drift over time.
The standard deviation of the drift prediction errors is
called the Hadamard Deviation.

This is a measure of stability where even drift, as long
as it's constant, is not a bad thing. In the summation
you'll see P3 - 3*P2 + 3*P1 - P0. You can see why
constant phase, frequency, or even drift doesn't affect
the sum.

----

So imagine a situation where you're making a GPSDO
and very long-term holdover performance is a key design
feature. What OCXO spec is important?

In this application phase error is easy to fix - you just
reset the epoch.

Frequency error is easy to fix. After some minutes or
perhaps hours you get a good idea of the frequency
offset. You then just set the EFC DAC to a calculated
value and maintain it during hold-over. In this case the
OCXO with the lowest drift rate (best Allan Deviation)
is the one to choose.

But with a little programming even drift is also easy to
fix. After some days or perhaps weeks you get a pretty
good idea of frequency drift over time and so you ramp
the EFC DAC over time to compensate.

The only limitation to extended hold-over performance
in such a GPDO is irregularity in drift rate.

In this example, the Hadamard Deviation would be a
good statistic to use to qualify the OCXO you need.
Drift, as long as it's constant (e.g., fixed, linear, even
log, or other prediction model) is not the limitation.

/tvb