Function Repository Resource:

SkewnessAround

Source Notebook

Calculate the skewness of a list along with its uncertainty

Contributed by: Sander Huisman

ResourceFunction["SkewnessAround"][{x1,x2,x3,}]

gives an Around object describing the skewness and corresponding uncertainty of the xi.

Details

The standard error of the skewness is defined as: , where n is the number of samples.
The "Value" of the Around object is calculated using the built-in Skewness function.

Examples

Basic Examples (1) 

Calculate the skewness of some numbers:

In[1]:=
ResourceFunction["SkewnessAround"][{1.1, 2.2, 2.6, 1.4, 2.2, 2.3}]
Out[1]=

Scope (2) 

SkewnessAround works with symbolic expressions:

In[2]:=
ResourceFunction["SkewnessAround"][{a, b, c, d}]
Out[2]=

SkewnessAround also works with quantities with units, though the answer is dimensionless:

In[3]:=
values = {Quantity[1, "Meters"], Quantity[1.1, "Meters"], Quantity[0.98, "Meters"], Quantity[0.99, "Meters"]};
ResourceFunction["SkewnessAround"][values]
Out[4]=

The skewness is independent of the units of course:

In[5]:=
ResourceFunction["SkewnessAround"][UnitConvert[values, "Feet"]]
Out[5]=

Possible Issues (3) 

SkewnessAround applied to symbolic expressions can get unwieldy fast:

In[6]:=
ResourceFunction[
 "SkewnessAround"][{a, b, c, d, e, f, g, h, i, j, k, l}]
Out[6]=

At least three value are needed to give a plausible error estimate:

In[7]:=
ResourceFunction["SkewnessAround"][{1, 2}]
Out[7]=

Try with 3 values:

In[8]:=
ResourceFunction["SkewnessAround"][{1, 2, 4}]
Out[8]=

Skewness can give Indeterminate, in which case there will not be an Around result:

Neat Examples (1) 

Study the skewness and its uncertainty for a sequence of values and compare it to the theoretical value of the distribution (dashed):

In[9]:=
SeedRandom[4321];
dist = SkewNormalDistribution[2, 3, 3];
vals = RandomVariate[dist, 10^7];
values = Table[{n, ResourceFunction["SkewnessAround"][Take[vals, n]]}, {n, Round[10^Range[1.25, Log10@Length[vals], 1/6]]}];
ListLogLinearPlot[values, PlotRange -> {0, 1}, GridLines -> {{}, {Skewness[dist]}}, GridLinesStyle -> Dashed, AxesLabel -> {"Number of values", "Estimate of the skewness"}, ImageSize -> 500]
Out[13]=

Publisher

SHuisman

Version History

  • 1.0.0 – 21 November 2022

Source Metadata

Related Resources

License Information