This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Allan variance


[avar,tau] = allanvar(omega)
[avar,tau] = allanvar(omega,m)
[avar,tau] = allanvar(omega,ptStr)
[avar,tau] = allanvar(___,fs)


[avar,tau] = allanvar(omega) returns the Allan variance avar as a function of sample length tau. If omega is specified as a matrix, allanvar operates over the columns of omega.

[avar,tau] = allanvar(omega,m) returns the Allan variance for specific values of τ, defined by m.

[avar,tau] = allanvar(omega,ptStr) sets tau to the specified ptStr.


[avar,tau] = allanvar(___,fs) specifies the sample rate of omega at fs Hz. This input parameter can be used with any of the previous syntaxes.


collapse all

Load gyroscope data from a MAT file, including the sample rate of the data in Hz. Calculate the Allan variance.

[avar,tau] = allanvar(omega,'octave',Fs);

Plot the Allan variance on a loglog plot.

title('Allan Variance')
grid on

Generate sample gyroscope noise, including angle random walk and rate random walk.

numSamples = 1e6;
Fs = 100;
nStd = 1e-3;
kStd = 1e-7;
nNoise = nStd.*randn(numSamples,1);
kNoise = kStd.*cumsum(randn(numSamples,1));
omega = nNoise+kNoise;

Calculate the Allan deviation at specific values of m=τ. The Allan deviation is the square root of the Allan variance.

m = 2.^(9:18);
[avar,tau] = allanvar(omega,m,Fs);
adev = sqrt(avar);

Plot the Allan deviation on a loglog plot.

title('Allan Deviation')
grid on

Input Arguments

collapse all

Input array specified as a vector, matrix, or multidimensional array. If specified as a matrix, allanvar operates over the columns of omega.

Data Types: single | double

Specific values of τ at which to calculate Allan variance, specified as a scalar or vector with ascending integer values less than (N-1)/2, where N is the number of elements in omega. m is not the index of omega.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Point specification of tau, specified as:

  • 'octave'


  • 'decade'


N is the number of samples in omega.

Sample rate of input array in Hz, specified as a positive scalar.

Data Types: single | double

Output Arguments

collapse all

Allan variance of input array at tau, specified as a vector, matrix, or multidimensional array.

Sample lengths corresponding to values of output. Specify this parameter by octave or decade using ptStr.


Allan variance can be used to measure the frequency stability of precision oscillators or identify sources of noise in gyroscope data. Consider N samples of data from a gyroscope with a sample time of τ0. Form data clusters of durationsτ0, 0, …, 0, where m is less than half of N. Then, obtain the averages of the sum of the data points contained in each cluster over the length of the cluster. The Allan variance is defined as the two-sample variance of the data cluster averages as a function of cluster time. This function calculates overlapping Allan variance.

Introduced in R2019a