Function Repository Resource:

CircularMoment

Source Notebook

Compute the trigonometric circular moment

Contributed by: Sander Huisman

ResourceFunction["CircularMoment"][list,p]

calculates the p-th power trigonometric circular moment of list.

ResourceFunction["CircularMoment"][listweights,p]

uses the weights weights.

Details

The data is assumed to be in radians.
ResourceFunction["CircularMoment"] calculates the trigonometric circular moment of 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 circular moment takes into account the discontinuity around 0 and 2π for calculating the trigonometric moment.

Examples

Basic Examples (1) 

Calculate the magnitude and angle of the second moment of some angular data:

In[1]:=
ResourceFunction[
 "CircularMoment", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][{0.9, 1.2, 0.7, 1.9, 0.5, 6.2}, 2]
Out[1]=

Scope (2) 

Use some weights:

In[2]:=
data = {0.3, 0.1, 0.05, 6.2, 6.1};
weights = {0.1, 1, 1, 1, 0.1};
ResourceFunction[
 "CircularMoment", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][data -> weights, 2]
Out[4]=

Powers do not have to be integers:

In[5]:=
ResourceFunction[
 "CircularMoment", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][{0.3, 0.1, 0.05, 6.2, 6.1}, 2.5]
Out[5]=

Properties and Relations (1) 

The first order agrees with the "CircularMean" resource function:

In[6]:=
data = RandomVariate[NormalDistribution[2.5, 0.5], 1000];
ResourceFunction[
   "CircularMoment", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][data, 1]["Angle"] == ResourceFunction["CircularMean"][data]
Out[7]=

Possible Issues (2) 

An empty list spawns an error:

In[8]:=
ResourceFunction[
 "CircularMoment", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][{}, 1]
Out[8]=

The data and the weights should have the same lengths:

In[9]:=
ResourceFunction[
 "CircularMoment", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][{1, 1.2, 1.1} -> {1, 1, 3, 4}, 2]
Out[9]=

Neat Examples (2) 

Visualize the circular moment for the first 10 powers of some random data that is uniformly distributed between 0 and π/3:

In[10]:=
SeedRandom[1];
data = RandomReal[{0, Pi/3}, 100];
data = Table[
   cm = ResourceFunction[
     "CircularMoment", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][data, p];
   {p, AngleVector[{cm["Magnitude"], cm["Angle"]}]}, {p, 10}];
Graphics[{Red, Arrow[{{0, 0}, #2}], Text[#1, #2 + 0.1 Normalize[#2]]} & @@@ data, Axes -> True]
Out[13]=

Plot the magnitude as a function of the power:

In[14]:=
data = {0.3, 0.1, 0.05, 6.2, 6.1};
cm = ResourceFunction[
   "CircularMoment", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][data, a];
Plot[cm["Magnitude"], {a, 0, 30}]
Out[16]=

Publisher

SHuisman

Version History

  • 1.0.0 – 24 November 2025

Related Resources

License Information