Function Repository Resource:

AroundHistogramList

Source Notebook

Calculate a histogram with Around objects and numbers

Contributed by: Sander Huisman

ResourceFunction["AroundHistogramList"][ptsi,{xmin,xmax,δx}

gives a list of bins and counts of the Around objects or numbers ptsi with bins from xmin to xmax with bins of width δx.

Details

Around objects are "modeled" as normal distributions and this count is then "redistributed" over the bins.
The output is the bin borders and the counts in each bin.
ResourceFunction["AroundHistogramList"] supports numerical Around objects and regular numbers.
Around objects with asymmetric uncertainties are supported.

Examples

Basic Examples (2) 

Generate a list of bin delimiters and counts for a list of Around objects:

In[1]:=
{bins, counts} = ResourceFunction[
  "AroundHistogramList"][{Around[2.13, 0.3], Around[7, 0.7], Around[10.1, 0.4]}, {-5, 15, 0.25}]
Out[1]=

Visualize the histogram:

In[2]:=
ListPlot[Transpose[{MovingAverage[bins, 2], counts}], PlotRange -> All]
Out[2]=

Scope (2) 

Numbers and Around objects can be mixed:

In[3]:=
{b, c} = ResourceFunction[
   "AroundHistogramList"][{Around[2.13, 0.15], 1, 4.2, 3}, {0, 5, 0.25}];
ListPlot[Transpose[{MovingAverage[b, 2], c}], PlotRange -> All]
Out[3]=

Around objects with asymmetric errors are also supported:

In[4]:=
{b, c} = ResourceFunction[
   "AroundHistogramList"][{Around[2.13, {0.3, 0.6}]}, {0, 5, 0.1}];
ListPlot[Transpose[{MovingAverage[b, 2], c}], PlotRange -> All]
Out[4]=

Possible Issues (1) 

Symbolic Around objects are not supported:

In[5]:=
ResourceFunction[
 "AroundHistogramList"][{Around[x, y], 1, 4.2, 3}, {0, 5, 0.25}]
Out[5]=

Publisher

SHuisman

Version History

  • 1.0.0 – 26 May 2021

Related Resources

License Information