Skip to main content

Allan deviation and related time/frequency statistics

Project description


A python library for calculating Allan deviation and related time & frequency statistics. GPL v3+ license.

Developed at and also available on PyPi at

Input data should be evenly spaced observations of either fractional frequency, or phase in seconds. Deviations are calculated for given tau values in seconds.

These statistics are currently included:

  • adev() Allan deviation

  • oadev() overlapping Allan deviation,

  • mdev() modified Allan deviation,

  • tdev() Time deviation

  • hdev() Hadamard deviation

  • ohdev() overlapping Hadamard deviation

  • totdev() total Allan deviation

  • mtie() Maximum time interval error

  • tierms() Time interval error RMS

  • mtotdev() Modified total deviation

  • ttotdev() Time total deviation

  • htotdev() Hadamard total deviation

  • theo1() Thêo1 deviation

Noise generators for creating synthetic datasets are also included:

  • violet noise with f^2 PSD

  • white noise with f^0 PSD

  • pink noise with f^-1 PSD

  • Brownian or random walk noise with f^-2 PSD

see /tests for tests that compare allantools output to other (e.g. Stable32) programs. More test data, benchmarks, ipython notebooks, and comparisons to known-good algorithms are welcome!


See /docs for documentation in sphinx format. On Ubuntu this requires the python-sphinx and python-numpydoc packages. html/pdf documentation using sphinx can be built locally with:

/docs$ make html
/docs$ make latexpdf

this generates html documentation in docs/_build/html and pdf documentation in docs/_build/latex.

The sphinx documentation is also auto-generated online

IPython notebooks with examples

See /examples for some examples in IPython notebook format.

github formats the notebooks into nice web-pages, for example

todo: add here a very short guide on how to get started with ipython



clone from github, then install with:

sudo python install

(see python –help install for install options)

or download from pypi:

sudo pip install allantools


import allantools #
rate = 1/float(data_interval_in_s) # data rate in Hz
taus = [1,2,4,8,16] #  tau-values in seconds
# fractional frequency data
(taus_used, adev, adeverror, adev_n) = allantools.adev(frequency=fract_freqdata, rate=rate, taus=taus)
# phase data
(taus_used, adev, adeverror, adev_n) = allantools.adev(phase=phasedata, rate=rate, taus=taus)

# notes:
#  - taus_used may differ from taus, if taus has a non-integer multiples
#  of data_interval - adeverror assumes 1/sqrt(adev_n) errors


Here follows an un-ordered to do list:

  • Statistics

    • The mtie_phase_fast approach to MTIE, using a binary tree (see BREGNI reference)

    • TheoH

  • Improve documentation

  • Improve packaging for PyPi and/or other packaging systems (PPA for Ubuntu/Debian?)

  • Stable32-style plots using matplotlib

  • Tests for different noise types according to IEEE 1139, include power-spectral-density calculations

  • Conversion between phase noise and Allan variance

  • Phase noise calculations and plots

  • Comparison to other libraries such as GPSTk

Make sure your patch does not break any of the tests, and does not significantly reduce the readability of the code.


The tests compare the output of allantools to other programs such as Stable32.

Tests may be run using py.test ( (automatically finds tests/ Test coverage may be obtained with the ( module:

coverage run --source allantools test
coverage report # Reports on standard output
coverage html # Writes annotated source code as html in ./htmlcov/

On Ubuntu this requires packages python-pytest and python-coverage.

Notes for Pypi

Creating a source distribution

python sdist

Testing the source distribution. The install takes a long time while compiling nympy and scipy.

$ virtualenv tmp
$ tmp/bin/pip install dist/AllanTools-2016.2.tar.gz
$ tmp/bin/python
>>> import allantools

Registering, uploading and testing source distribution to PyPi test server (requries a ~/.pypirc with username and password)

$ python register -r test
$ python sdist upload -r test
$ pip install -i AllanTools

Registering and uploading to PyPi

$ python register
$ python sdist upload


1139-2008 - IEEE Standard Definitions of Physical Quantities for Fundamental Frequency and Time Metrology - Random Instabilities

F. Vernotte, “Variance Measurements”, 2011 IFCS & EFTF

S. Stein, Frequency and Time - Their Measurement and Characterization. Precision Frequency Control Vol 2, 1985, pp 191-416.


Tom Van Baak

Fabian Czerwinski, Matlab code

M. A. Hopcroft, Matlab code

SESIA I., GALLEANI L., TAVELLA P., Application of the Dynamic Allan Variance for the Characterization of Space Clock Behavior,

S. BREGNI, Fast Algorithms for TVAR and MTIE Computation in Characterization of Network Synchronization Performance.

David A. Howe, The total deviation approach to long-term characterization of frequency stability, IEEE tr. UFFC vol 47 no 5 (2000)

Ilaria Sesia and Patrizia Tavella, Estimating the Allan variance in the presence of long periods of missing data and outliers. 2008 Metrologia 45 S134

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

AllanTools-2016.3.tar.gz (23.6 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page