Function Repository Resource:

CircularVariance

Source Notebook

Computes the circular variance

Contributed by: Sander Huisman

ResourceFunction["CircularVariance"][list]

calculates the circular variance for the circular data list.

ResourceFunction["CircularVariance"][listweights]

calculates the circular variance for the circular data list using the weights weights.

Details

The data is assumed to be angles in radians.
This function calculate the variance of the data assuming it is in a periodic domain of 0–2π. The input data can have any value and does not need to be in this range. This variance takes into account the discontinuity around 0 and 2π for calculating the variance.
The circular variance gives a value between 0 and 1 and is not the square of the circular standard deviation.

Examples

Basic Examples (1) 

Calculate the circular variance from some data:

In[1]:=
data = {0.3, 0.1, 0.05, 6.2, 6.1};
ResourceFunction["CircularVariance"][data]
Out[2]=

Scope (1) 

Provide weights:

In[3]:=
data = {0.3, 0.1, 0.05, 6.2, 6.1};
weights = {0.1, 1, 1, 1, 0.1};
ResourceFunction["CircularVariance"][data -> weights]
Out[4]=

Properties and Relations (3) 

Visualize some data:

In[5]:=
data = {0.3, 0.1, 0.05, 6.2, 6.1};
Graphics[{Circle[], PointSize[Large], Point[AngleVector /@ data]}]
Out[6]=

Using the standard Variance does not take into account the circularity and the result will be much larger:

In[7]:=
Variance[data]
Out[7]=

Taking the circular nature into account give the expected result:

In[8]:=
ResourceFunction["CircularVariance"][data]
Out[8]=

For small spread the circular variance is approximately half the 'linear' variance:

In[9]:=
var = 0.04;
data = RandomVariate[NormalDistribution[1.3, Sqrt[var]], 10000];
{ResourceFunction["CircularVariance"][data], var/2}
Out[11]=

For constant data the variance is equal to 0:

In[12]:=
ResourceFunction["CircularVariance"][{1, 1, 1}]
Out[12]=

Possible Issues (2) 

An empty list spawns an error but returns 0:

In[13]:=
ResourceFunction["CircularVariance"][{}]
Out[13]=

The data and the weights should be commensurate:

In[14]:=
ResourceFunction["CircularVariance"][{1, 1.2, 1.1} -> {1, 1, 3, 4}]

Neat Examples (1) 

The circular variance approaches 1 for a uniform distribution:

In[15]:=
Table[{p, ResourceFunction["CircularVariance"][
    RandomReal[{0, 2 Pi}, 10^p]]}, {p, 8}] // Grid
Out[15]=

Publisher

SHuisman

Version History

  • 1.0.0 – 14 November 2025

Related Resources

License Information