*Updated April 24, 2023*

The Moku:Lab Phasemeter measures phase with up to 6 µradian precision for input signals oscillating between 1 kHz and 200 MHz. Using a digitally implemented phase-locked loop architecture, it provides exceptional dynamic range and precision far exceeding the capabilities of conventional lock-in amplifiers and frequency counters. The Moku:Lab Phasemeter calculates and plots Allan Deviation, which is a unitless measure of stability, typically used to quantify the stability of clocks and other oscillators. In this guide, we will cover the math and provide an example Allan Deviation calculation with the overlapped variable * τ* estimator. This procedure is also compatible with the Moku:Pro Phasemeter.

## Allan Deviation with overlapped variable τ estimators

Allan Deviation is a unitless measure of stability, typically used to quantify the stability of clocks and other oscillators. By definition, Allan Deviation * σ_{y}* is calculated as a function of observation time

*by the following equation:*

**τ**where * x* is the phase measured over time. In practice, it’s not possible to calculate the expected value over infinite time. Several estimators are used to calculate Allan deviation. Moku:Lab uses the overlapped variable

*estimator to calculate the Allan Deviation, which is defined as:*

**τ**where * τ_{0}* is the sampling period of the Phasemeter and

*is the number of data points acquired for the input time series. n is an integer multiplier of the sampling period that best estimates the desired*

**N***.*

**τ≅n**_{τ}0*represents the ith element in the time series.*

**x**_{i}## Allan Deviation with the Moku:Lab Phasemeter

In this example, we measured the Allan deviation of a 2 MHz signal with Moku:Lab Phasemeter. The frequency and phase of the signal were measured at 122 Hz for 10 minutes. To display the Allan Deviation, select the “Phase” tab on the top of the Moku display and “Allan Deviation” in the plot area.

**Please note, if “Frequency” or “Amplitude” tabs are selected, Moku:Lab will use frequency or amplitude time series as the input for Equation (2).**

## Python implementation

The function cal_oadev takes the time series, sampling rate and an array of observation time * τ* as the input. It calculates the overlapped Allan deviation using equation (2) and returns the

*and*

**n**_{τ}0*(*

**σ**_{y}*) as arrays. Required Libraries: NumPy, math*

**nτ**_{0}#Import libraries

import numpy as np

import math

def cal_oadev(data,rate,tauArray):

tau0 = 1/rate #Calculate the sampling period

dataLength = data.size #Calculate N

dev = np.array([]) #Create empty array to store the output.

actualTau = np.array([])

for i in tauArray:

n = math.floor(i/tau0) #Calculate n given a tau value.

if n == 0:

n = 1 #Use minimal n if tau is less than the sampling period.

currentSum = 0 #Initialize the sum

for j in range(0,dataLength-2*n):

currentSum = (data[j+2*n]-2*data[j+n]+data[j])**2+currentSum

#Cumulate the sum squared

devAtThisTau = currentSum/(2*n**2*tau0**2*(dataLength-2*n))

#Divide by the coefficient

dev = np.append(dev,np.sqrt(devAtThisTau))

actualTau = np.append(actualTau,n*tau0)

return actualTau, dev #Return the actual tau and overlapped Allan deviation

## Example calculation

In this example, we imported the time series we acquired previously on the Moku:Lab and calculated the Allan Deviation with Python scripts. You can find all the raw data and scripts below.

The time series can be found in the “data.xlsx” file. The first column “A” is the measured frequency in Hz, and the second column “B” is the measured phase in cycles. The script “CalculateAllanDeviation.py” reads the excel file and calls the cal_oadev function in the “AllanFunc.py”. The Allan Deviation is plotted as a function of * τ* in log scales. The Allan Deviation plots matched well between the Moku:Lab and Python scripts. Required Libraries: NumPy, math, pandas, Matplotlib

## References

[1] Land, D. V., A. P. Levick, and J. W. Hand. “The use of the Allan deviation for the measurement of the noise and drift performance of microwave radiometers.” *Measurement Science and Technology* 18, no. 7 (2007): 1917.

[2] Allan, David W. “Statistics of atomic frequency standards.” *Proceedings of the IEEE* 54.2 (1966): 221-230.

[3] Howe, D.A., Allan, D.W., and Barnes, J.A. “Properties of signal sources and measurement methods.” Proceedings of the 35th Annual Symposium on Frequency Control (1981): TN-14 – TN-60.