Histogramming, grouping, and binning#

Overview#

Histogramming (see sc.hist), grouping (using sc.groupby), and binning (see Binned data) all serve similar but slightly different purposes. Picking the optimal one of the three for a particular application may yield more natural code and better performance. Let us start by an example. Consider a table of scattered measurements:

[1]:
import numpy as np
import scipp as sc
N = 5000
values = 10*np.random.rand(N)
table = sc.DataArray(
    data=sc.array(dims=['position'], unit=sc.units.counts, values=values, variances=values),
    coords={
        'x':sc.array(dims=['position'], unit='m', values=np.random.rand(N)),
        'y':sc.array(dims=['position'], unit='m', values=np.random.rand(N))
    })
table.values *= 1.0/np.exp(5.0*table.coords['x'].values)
sc.table(table['position', :5])
[1]:
CoordinatesData
x [m]y [m] [counts]
0.3490.4830.170±0.987
0.2140.3090.774±1.501
0.1660.5681.438±1.817
0.0690.2986.198±2.960
0.5050.7100.798±3.158

We may now be interested in the total intensity (counts) as a function of 'x'. There are three ways to do this:

[2]:
xbins = sc.linspace('x', 0, 1, num=40, unit='m')
ds = sc.Dataset()
ds['histogram'] = table.hist(x=xbins)
ds['groupby'] = table.groupby('x', bins=xbins).sum('position')
ds['bin'] = table.bin(x=xbins).bins.sum()
ds.plot()
[2]:
../../_images/user-guide_binned-data_histogramming-grouping-and-binning_3_0.svg

In the above plot we can only see a single line, since the three solutions yield exactly the same result (neglecting floating-point rounding errors):

  • hist sorts data points into ‘x’ bins, summing immediately.

  • groupby groups by ‘x’ and then sums (on-the-fly) all data points falling in the same ‘x’ bin.

  • bin sorts data points into ‘x’ bins. Summing all rows in a bin yields the same result as grouping and summing directly.

So in this case we get equivalent results, but the application areas differ, as described in more detail in the following sections.

Histogramming#

scipp.hist directly sums the data and is efficient. Limitations are:

  • When histogramming in more than one dimension, the implementation uses sc.bin internally, which may be less efficient and uses more memory.

  • Can only apply “sum” or “nansum” to accumulate into a bin. scipp.nanhist is currently implemented differently and uses sc.bin internally. It therefore uses more memory and may be less efficient.

We can also histogram binned data (since binning preserves the 'y' coord), to create 2-D (or N-D) histograms:

[3]:
binned = table.bin(x=xbins)
hist = binned.hist(y=30)
hist.plot()
[3]:
../../_images/user-guide_binned-data_histogramming-grouping-and-binning_5_0.svg
[4]:
hist
[4]:
Show/Hide data repr Show/Hide attributes
scipp.DataArray (20.09 KB)
    • x: 39
    • y: 30
    • x
      (x [bin-edge])
      float64
      m
      0.0, 0.026, ..., 0.974, 1.0
      Values:
      array([0. , 0.02564103, 0.05128205, 0.07692308, 0.1025641 , 0.12820513, 0.15384615, 0.17948718, 0.20512821, 0.23076923, 0.25641026, 0.28205128, 0.30769231, 0.33333333, 0.35897436, 0.38461538, 0.41025641, 0.43589744, 0.46153846, 0.48717949, 0.51282051, 0.53846154, 0.56410256, 0.58974359, 0.61538462, 0.64102564, 0.66666667, 0.69230769, 0.71794872, 0.74358974, 0.76923077, 0.79487179, 0.82051282, 0.84615385, 0.87179487, 0.8974359 , 0.92307692, 0.94871795, 0.97435897, 1. ])
    • y
      (y [bin-edge])
      float64
      m
      0.000, 0.033, ..., 0.967, 1.000
      Values:
      array([1.66752674e-04, 3.34919054e-02, 6.68170580e-02, 1.00142211e-01, 1.33467363e-01, 1.66792516e-01, 2.00117669e-01, 2.33442821e-01, 2.66767974e-01, 3.00093127e-01, 3.33418279e-01, 3.66743432e-01, 4.00068585e-01, 4.33393738e-01, 4.66718890e-01, 5.00044043e-01, 5.33369196e-01, 5.66694348e-01, 6.00019501e-01, 6.33344654e-01, 6.66669806e-01, 6.99994959e-01, 7.33320112e-01, 7.66645264e-01, 7.99970417e-01, 8.33295570e-01, 8.66620722e-01, 8.99945875e-01, 9.33271028e-01, 9.66596180e-01, 9.99921333e-01])
    • (x, y)
      float64
      counts
      8.843, 23.819, ..., 0.176, 0.210
      σ = 3.120, 4.994, ..., 4.944, 5.411
      Values:
      array([[ 8.84325644, 23.81860976, 49.4976635 , ..., 3.2135056 , 13.45829025, 14.04592603], [42.74222002, 18.39388409, 12.75192563, ..., 46.46322584, 6.52778616, 11.79280919], [21.48789334, 16.11954921, 0. , ..., 9.82269106, 21.96689844, 14.04321256], ..., [ 0.21908713, 0.22260487, 0.1974337 , ..., 0.09024851, 0.20105889, 0.41550927], [ 0.41132585, 0.23171099, 0.18533479, ..., 0.20527199, 0.19933816, 0.15076266], [ 0.22117646, 0.07388296, 0.28080816, ..., 0.07041057, 0.17599879, 0.21047286]])

      Variances (σ²):
      array([[ 9.73612674, 24.93789928, 52.11755855, ..., 3.48638267, 14.41914251, 14.28772168], [52.80128181, 22.22555888, 15.56847396, ..., 56.13397291, 8.0005368 , 14.04364146], [29.35380961, 21.40488388, 0. , ..., 13.16919082, 31.65339085, 19.48055248], ..., [23.6604271 , 23.07548767, 22.12024326, ..., 9.40524155, 21.65074116, 44.6613208 ], [51.31806853, 27.95875222, 22.98567965, ..., 24.56105537, 24.81783993, 18.35878785], [31.40714635, 10.82869794, 38.38862395, ..., 10.09899177, 24.44543063, 29.28121435]])

Another capability of hist is to histogram a dimension that has previously been binned with a different or higher resolution, i.e. different bin edges. Compare to the plot of the initial example:

[5]:
binned = table.bin(x=xbins)
binned.hist(x=100).plot()
[5]:
../../_images/user-guide_binned-data_histogramming-grouping-and-binning_8_0.svg

Grouping#

groupby is more flexible in terms of operations than can be applied and may be the go-to solution when a quick one-liner is required. Limitations are:

  • Can only group along a single dimension.

  • Works best for small to medium-sized data, or if data is already mostly sorted along the grouping dimension. Slow if millions of small input slices contribute to each group.

groupby can also operate on binned data, combining bin contents by concatenation:

[6]:
binned = table.bin(x=xbins)
binned.coords['param'] = sc.array(dims=['x'], values=(np.random.random(39)*4).astype(np.int32))
grouped = binned.groupby('param').bins.concat('x')
grouped
/home/runner/work/scipp/scipp/.tox/docs/lib/python3.8/site-packages/scipp/core/bins.py:465: UserWarning: groupby(...).bins.concat(dim) is deprecated. Use `group` or `bin` instead
  warnings.warn(
[6]:
Show/Hide data repr Show/Hide attributes
scipp.DataArray (158.70 KB)
    • param: 4
    • param
      (param)
      int32
      𝟙
      0, 1, 2, 3
      Values:
      array([0, 1, 2, 3], dtype=int32)
    • (param)
      DataArrayView
      binned data [len=611, len=1431, len=1569, len=1389]
      dim='position',
      content=DataArray(
                dims=(position: 5000),
                data=float64[counts],
                coords={'x':float64[m], 'y':float64[m]})

Each output bin is a combination of multiple input bins:

[7]:
grouped.values[0]
[7]:
Show/Hide data repr Show/Hide attributes
scipp.DataArray (20.35 KB out of 157.50 KB)
    • position: 611
    • x
      (position)
      float64
      m
      0.166, 0.170, ..., 0.946, 0.924
      Values:
      array([0.16623062, 0.16959726, 0.17714428, 0.17067054, 0.17086983, 0.16755735, 0.15620351, 0.17422382, 0.16245675, 0.15422015, 0.17783141, 0.17168246, 0.16902034, 0.17226067, 0.1749174 , 0.15817696, 0.1544267 , 0.17866485, 0.16599251, 0.17258198, 0.16761383, 0.1654829 , 0.15988281, 0.171422 , 0.17751625, 0.15717724, 0.15620496, 0.16016751, 0.17198831, 0.15598394, 0.17550344, 0.1775013 , 0.15550443, 0.1713457 , 0.1698871 , 0.16242233, 0.16375915, 0.15851099, 0.17932639, 0.16586385, 0.16323553, 0.1764439 , 0.17939916, 0.15393702, 0.17450054, 0.15500441, 0.1644631 , 0.17469946, 0.15957873, 0.15884629, 0.16845344, 0.16163639, 0.16659214, 0.17911298, 0.17839274, 0.17849883, 0.16283144, 0.16789258, 0.17276021, 0.17385086, 0.17607483, 0.16005934, 0.16165143, 0.16073825, 0.17272385, 0.17906429, 0.17944286, 0.16211516, 0.17641261, 0.15807982, 0.16774863, 0.1732738 , 0.17154796, 0.16853811, 0.17452657, 0.16943665, 0.16925906, 0.15982585, 0.15943319, 0.16203865, 0.15430434, 0.1559722 , 0.16227542, 0.16538665, 0.16405034, 0.16552512, 0.15826079, 0.17390169, 0.16112362, 0.16743638, 0.15656114, 0.15844926, 0.17460919, 0.17882411, 0.16642464, 0.17567652, 0.17073171, 0.15846124, 0.1685491 , 0.17401776, 0.17037582, 0.15823511, 0.16811748, 0.17783674, 0.3130209 , 0.32950653, 0.31446675, 0.32719881, 0.33017443, 0.32098889, 0.33033292, 0.31931774, 0.31686027, 0.32479802, 0.30788215, 0.30833042, 0.31440921, 0.31698414, 0.32533547, 0.3215119 , 0.3199565 , 0.32144652, 0.31519821, 0.33019969, 0.32007501, 0.3193552 , 0.33293323, 0.32612721, 0.33319806, 0.31325775, 0.32332519, 0.33107036, 0.32805035, 0.32091021, 0.31400754, 0.30977487, 0.32768071, 0.31873234, 0.31919244, 0.31002119, 0.32771638, 0.31635796, 0.33132485, 0.32046736, 0.32808179, 0.31930197, 0.32059225, 0.32689642, 0.32124918, 0.31349689, 0.3200934 , 0.30975895, 0.33044384, 0.33054553, 0.3185849 , 0.32896429, 0.31063837, 0.31508211, 0.31316246, 0.32735233, 0.32528419, 0.32308991, 0.32188981, 0.30925673, 0.31840113, 0.31027877, 0.30845147, 0.3174129 , 0.31725453, 0.31719896, 0.32536371, 0.31620573, 0.32876242, 0.31746222, 0.32097118, 0.33183029, 0.33104959, 0.31216888, 0.31133571, 0.31019222, 0.31493874, 0.31535975, 0.32334888, 0.31839727, 0.31398956, 0.30909804, 0.30955314, 0.3089585 , 0.31399983, 0.31539216, 0.30870526, 0.31791634, 0.31465527, 0.32725448, 0.30980983, 0.32515943, 0.3139235 , 0.31915294, 0.31598845, 0.32874886, 0.31171066, 0.31792794, 0.32039257, 0.31217099, 0.32090551, 0.31525853, 0.30865961, 0.31771456, 0.32185362, 0.329637 , 0.32786312, 0.31297771, 0.32689484, 0.30990464, 0.30787599, 0.30852252, 0.3303792 , 0.32063048, 0.33293567, 0.33082871, 0.33297178, 0.31224668, 0.31074131, 0.33118873, 0.32150701, 0.32015231, 0.33282743, 0.32997339, 0.31073219, 0.31276993, 0.31221705, 0.32523175, 0.32259392, 0.5492997 , 0.54538203, 0.55706309, 0.5390817 , 0.5430496 , 0.56152987, 0.54579998, 0.55186594, 0.5428441 , 0.56160149, 0.53916292, 0.54406354, 0.5448375 , 0.54820591, 0.54365308, 0.53868583, 0.56386394, 0.53884119, 0.54418231, 0.55699233, 0.54553316, 0.55064185, 0.54688264, 0.56307469, 0.53886329, 0.55201005, 0.54886765, 0.55291413, 0.56351614, 0.54388377, 0.54398797, 0.55665351, 0.55239272, 0.56183106, 0.56142318, 0.54613331, 0.55720573, 0.56008976, 0.56137855, 0.56040533, 0.54788767, 0.54772494, 0.55623917, 0.55651709, 0.53929945, 0.55114031, 0.53865435, 0.54626629, 0.55243098, 0.56304796, 0.54171313, 0.55919042, 0.55090238, 0.56230679, 0.55295964, 0.54178969, 0.54170069, 0.53975212, 0.54447749, 0.54116982, 0.54949731, 0.55460079, 0.55568737, 0.54329085, 0.54414635, 0.53882975, 0.54698468, 0.5422573 , 0.53881318, 0.5461602 , 0.55539812, 0.5455588 , 0.55560836, 0.54432668, 0.54650867, 0.55513434, 0.55722229, 0.54340388, 0.54050286, 0.5424626 , 0.54144961, 0.5586207 , 0.53933257, 0.54219155, 0.56219609, 0.54892747, 0.54275326, 0.56042135, 0.54853514, 0.55125561, 0.56320581, 0.55096224, 0.54778918, 0.54122881, 0.56359577, 0.53898513, 0.55505882, 0.56267519, 0.54679962, 0.54787596, 0.55339867, 0.54735976, 0.56267645, 0.55551107, 0.56101825, 0.55362155, 0.55509075, 0.54868701, 0.5419509 , 0.55475999, 0.56254365, 0.5579733 , 0.55460893, 0.55023279, 0.54627665, 0.54222767, 0.54471468, 0.56009994, 0.54694928, 0.55659242, 0.55260865, 0.54681678, 0.55119665, 0.55867285, 0.54731906, 0.55110865, 0.55354044, 0.54048188, 0.55565855, 0.56196438, 0.54517542, 0.54193021, 0.56214038, 0.87306509, 0.89330341, 0.87188031, 0.89662531, 0.88920748, 0.87454549, 0.8854507 , 0.88913607, 0.88861006, 0.87918193, 0.88294885, 0.8926518 , 0.88953025, 0.88744021, 0.88235672, 0.89433098, 0.88743363, 0.87482837, 0.88689041, 0.87189561, 0.89434476, 0.89531636, 0.88256661, 0.87569228, 0.87705677, 0.89237373, 0.88735351, 0.87528919, 0.89049502, 0.89136696, 0.88828675, 0.88899813, 0.8924111 , 0.8964346 , 0.89659483, 0.88606748, 0.88018289, 0.88824418, 0.88728283, 0.88843329, 0.89683947, 0.88127238, 0.88514027, 0.89174157, 0.89614988, 0.87388971, 0.87857418, 0.87318296, 0.88276093, 0.88468732, 0.87807854, 0.89063065, 0.88624367, 0.89279543, 0.89490728, 0.87744419, 0.87653278, 0.88986367, 0.88607983, 0.87228778, 0.87515105, 0.89111206, 0.87700215, 0.8743639 , 0.87741402, 0.87651003, 0.88746867, 0.87734324, 0.88137722, 0.8857436 , 0.89024119, 0.87795067, 0.89693188, 0.88321626, 0.87701281, 0.8781875 , 0.88703763, 0.89230195, 0.88314443, 0.88311801, 0.89193051, 0.89043004, 0.89500665, 0.88815822, 0.88473846, 0.88270976, 0.89228737, 0.87733648, 0.895093 , 0.87445633, 0.8796071 , 0.87428304, 0.88600613, 0.89734545, 0.87608179, 0.87258422, 0.87710094, 0.87727844, 0.89140608, 0.87706529, 0.87357221, 0.88843955, 0.87266672, 0.88446349, 0.89619094, 0.87217439, 0.87644971, 0.89615408, 0.89046034, 0.89495109, 0.89431718, 0.89017405, 0.88669638, 0.89449641, 0.87341469, 0.8838654 , 0.88838185, 0.88805504, 0.89311528, 0.88362717, 0.94021533, 0.93953298, 0.94750165, 0.94095443, 0.92947841, 0.94785051, 0.94749856, 0.92373161, 0.93561133, 0.93372222, 0.94347731, 0.93617264, 0.93539816, 0.94457717, 0.94056326, 0.94414721, 0.94527455, 0.94201065, 0.94519508, 0.93874798, 0.93108128, 0.92894658, 0.93389473, 0.94202388, 0.94019997, 0.93650492, 0.9485419 , 0.93942252, 0.92543307, 0.93382522, 0.93115905, 0.94249557, 0.93478722, 0.93079231, 0.93029787, 0.92929107, 0.94426588, 0.92593626, 0.9453449 , 0.94431286, 0.93474349, 0.92660738, 0.93320563, 0.93118981, 0.93608068, 0.93409556, 0.92835925, 0.94152115, 0.93249188, 0.92590196, 0.93252099, 0.94641957, 0.93124998, 0.93430708, 0.93165103, 0.94051431, 0.93624151, 0.94189086, 0.93458488, 0.932657 , 0.94736407, 0.93663286, 0.94402769, 0.92746107, 0.93174196, 0.94189951, 0.94578282, 0.9348204 , 0.94462023, 0.93347625, 0.92538799, 0.93868924, 0.94433952, 0.94461178, 0.92731164, 0.93444919, 0.93143667, 0.92958798, 0.93057938, 0.92560045, 0.94572931, 0.94532174, 0.93136014, 0.92493617, 0.94121292, 0.93280436, 0.93455685, 0.93553998, 0.94429777, 0.94047695, 0.93134065, 0.94794393, 0.94503249, 0.93585616, 0.93802231, 0.94731957, 0.92422376, 0.92504472, 0.94131379, 0.92565941, 0.94315688, 0.94654081, 0.93794851, 0.93478544, 0.94860512, 0.931803 , 0.9468682 , 0.93584677, 0.92643272, 0.94193581, 0.92589306, 0.94574969, 0.92924225, 0.94421008, 0.93217173, 0.93668999, 0.93803239, 0.93043207, 0.92375555, 0.92896974, 0.92420731, 0.93199025, 0.94322307, 0.94629307, 0.92398253])
    • y
      (position)
      float64
      m
      0.568, 0.292, ..., 0.355, 0.893
      Values:
      array([5.68093248e-01, 2.92396230e-01, 3.33223977e-01, 7.03073265e-01, 3.16483427e-01, 5.45029362e-01, 5.66518279e-01, 8.62148454e-01, 3.98018300e-01, 6.19427760e-01, 5.40962142e-01, 5.24058083e-01, 2.84238461e-01, 6.48871740e-01, 6.72516305e-01, 1.49229156e-01, 9.97372844e-01, 7.35248664e-01, 4.00319755e-01, 2.85590263e-01, 5.47230133e-02, 2.19249487e-02, 9.48554475e-01, 5.60450929e-01, 3.18982842e-01, 6.55255212e-01, 3.22465949e-01, 2.44658314e-01, 9.02353063e-01, 7.20134859e-01, 8.35789197e-01, 1.64634340e-01, 2.21259231e-01, 6.26659648e-01, 1.68749221e-01, 2.63988737e-01, 5.00572357e-01, 7.50600604e-01, 8.63653078e-01, 8.11679029e-02, 9.33584291e-01, 6.72435291e-01, 9.48014854e-01, 6.75350436e-02, 8.89435507e-01, 9.09153130e-01, 6.63540796e-01, 5.55447298e-01, 1.33786783e-01, 8.93911061e-01, 5.89621896e-01, 1.42749675e-02, 1.35518126e-02, 7.93522505e-01, 6.33576570e-01, 3.50992840e-01, 2.69648938e-01, 5.47781157e-01, 7.78183557e-02, 4.34863202e-01, 1.03702524e-01, 7.46370120e-01, 5.49891961e-01, 9.37403693e-01, 2.71406077e-01, 9.49703318e-01, 9.51374654e-01, 8.70674104e-01, 6.45655289e-01, 9.23154281e-01, 3.04774776e-01, 9.14193482e-01, 3.90187395e-01, 3.23001972e-01, 7.78646527e-01, 9.76028454e-01, 1.87615801e-01, 9.60590244e-01, 4.03669819e-01, 9.70187524e-01, 7.67912274e-01, 8.01291289e-01, 6.07130723e-01, 7.36235780e-01, 4.61961942e-01, 3.16992755e-01, 8.24573240e-01, 6.59745956e-01, 1.23995067e-01, 4.81041164e-01, 3.04606466e-02, 2.12985046e-01, 3.16212109e-02, 7.96368129e-01, 6.86765634e-01, 9.93441203e-01, 2.78748376e-01, 8.87423644e-01, 3.02603889e-01, 8.38575318e-01, 3.00790743e-01, 1.74310849e-01, 5.71914205e-01, 3.39481419e-01, 9.29939584e-01, 7.02790469e-01, 3.97426272e-02, 3.61110802e-01, 2.89427219e-01, 4.50203069e-01, 1.43300696e-01, 4.23033592e-01, 6.84148551e-01, 4.07047470e-01, 9.45383171e-01, 2.56879067e-01, 6.38207748e-01, 9.78060311e-01, 4.55247237e-01, 6.69738273e-01, 6.62711492e-01, 7.43656347e-01, 9.53982506e-01, 2.62857924e-01, 6.07699673e-01, 1.98157769e-01, 1.04584479e-03, 4.31862439e-01, 6.35026953e-01, 5.72851333e-01, 4.52548406e-01, 2.65475389e-01, 5.51909397e-01, 7.91235821e-02, 1.72813021e-01, 1.46051768e-01, 6.40817727e-01, 4.55403761e-01, 5.90505149e-01, 2.93262873e-01, 9.22905803e-01, 4.83291840e-01, 9.29349026e-01, 7.52951631e-01, 5.13772937e-01, 5.17486141e-02, 3.15955864e-01, 9.41289381e-01, 5.20558166e-01, 9.13996080e-01, 1.16523825e-01, 8.03274450e-01, 4.73255239e-01, 2.02816666e-01, 1.30679721e-01, 8.79817174e-01, 9.63291272e-01, 7.80407781e-01, 1.04120645e-01, 3.32238035e-01, 1.66114324e-01, 8.88868963e-01, 9.68264522e-02, 1.01498619e-01, 3.86196978e-03, 1.66479190e-01, 1.88290783e-02, 8.73534103e-01, 2.33620612e-01, 5.31773679e-01, 6.27479615e-01, 9.53032030e-01, 9.35324676e-01, 3.07186057e-01, 6.62923216e-01, 5.16105851e-01, 2.98452762e-01, 5.02561292e-01, 6.03018267e-01, 9.03306357e-01, 1.05212870e-01, 1.80496477e-01, 8.82897432e-01, 6.60053013e-01, 7.37145719e-01, 9.30884598e-01, 4.32942476e-01, 3.93340979e-01, 1.03154016e-01, 3.02587821e-01, 6.23126997e-01, 1.27148516e-01, 6.81073502e-01, 3.01471964e-01, 4.79467416e-01, 6.42877741e-01, 5.64732036e-01, 1.86180288e-01, 7.47904334e-01, 2.03564744e-01, 6.77868376e-01, 6.86557084e-01, 3.18262816e-01, 3.05059279e-02, 7.06235628e-01, 2.70888725e-02, 5.75988034e-01, 5.61951635e-01, 7.62893771e-01, 9.64287681e-01, 3.09044410e-01, 4.15997672e-01, 3.32716136e-01, 1.85419763e-01, 5.69264868e-01, 9.06296653e-01, 8.08157772e-01, 1.73080708e-01, 8.87190329e-01, 8.17201724e-02, 8.84006094e-01, 2.78699983e-01, 9.76410239e-01, 7.29362439e-01, 8.44634566e-01, 1.66669208e-01, 5.96386388e-01, 1.02983402e-01, 2.56225484e-01, 1.00200476e-01, 1.24565685e-01, 5.02997224e-01, 6.01503958e-01, 2.20973085e-01, 6.02552231e-01, 3.80893508e-02, 3.07302538e-01, 3.05127131e-01, 7.34599946e-01, 9.39631554e-01, 3.19136658e-01, 9.84007825e-01, 3.92640504e-01, 6.77666994e-01, 9.33923330e-01, 7.95178241e-01, 6.37279932e-01, 5.35475604e-01, 7.99825784e-01, 2.08057120e-01, 7.56237375e-01, 1.15698574e-01, 5.56160489e-01, 1.75759904e-01, 7.43915691e-01, 1.71170092e-01, 3.57393087e-01, 8.03124772e-01, 4.50891989e-01, 2.06870899e-01, 9.80505554e-01, 8.76118294e-01, 3.02012894e-01, 9.54130088e-01, 5.57849386e-01, 8.92253644e-01, 4.87074376e-02, 6.28357874e-01, 1.94572098e-01, 9.19987832e-01, 1.50464182e-03, 1.32289376e-01, 2.18822168e-01, 3.76362723e-01, 2.56384280e-01, 4.68539421e-01, 4.53473857e-01, 6.37030257e-01, 6.92699896e-01, 3.26660188e-01, 8.25922885e-01, 5.54523266e-01, 9.89739142e-01, 7.13484060e-01, 6.91082737e-01, 3.37867359e-01, 4.99610067e-01, 3.09353406e-01, 2.59535034e-01, 9.03467281e-01, 7.21926443e-01, 7.17702362e-01, 8.19583424e-01, 3.49194419e-01, 3.66815501e-01, 8.64654665e-01, 7.73425536e-01, 4.26187135e-01, 6.01400814e-01, 4.65417937e-01, 6.12230207e-01, 2.24589642e-01, 3.41941361e-01, 8.32538827e-01, 5.43851875e-01, 2.65374504e-01, 8.85362569e-01, 7.96725902e-01, 8.28539562e-02, 7.79846644e-01, 8.36945630e-01, 2.41695099e-01, 5.98753053e-01, 6.26153681e-01, 6.58149016e-01, 6.58812248e-01, 9.86461560e-02, 5.43775674e-01, 9.10545137e-01, 8.07179567e-01, 4.97780452e-01, 4.10434855e-01, 1.79252002e-01, 7.89832930e-01, 4.52059808e-01, 5.17505074e-01, 5.45373272e-01, 4.83656700e-01, 7.15407143e-01, 1.54606242e-01, 5.27219617e-01, 8.43793030e-01, 8.34290919e-01, 6.41312689e-01, 3.23865868e-02, 3.64812520e-02, 1.35411037e-02, 2.57837760e-02, 7.35540818e-01, 6.32918411e-01, 3.96643260e-01, 2.33902134e-01, 1.81477751e-01, 6.35750736e-02, 2.58324789e-04, 9.27156257e-01, 6.59835825e-01, 4.26631258e-01, 2.05481698e-01, 6.95359278e-01, 3.27879344e-01, 7.41155376e-01, 5.67407936e-02, 2.99402859e-01, 9.02004892e-01, 8.08655364e-01, 1.52109459e-01, 4.50356964e-01, 7.04128347e-01, 1.23546992e-01, 8.89481805e-02, 6.39166712e-01, 9.69068614e-01, 3.57309210e-01, 2.54679301e-01, 6.06863072e-01, 4.85079175e-01, 4.37375708e-01, 7.95000942e-01, 1.70766654e-01, 7.96331290e-01, 8.37457316e-01, 6.96582658e-01, 7.21914871e-01, 1.29309639e-01, 1.56944752e-01, 8.81363802e-01, 1.38627250e-01, 1.02410200e-01, 9.74047632e-01, 5.51210922e-02, 5.43822246e-02, 8.56931796e-01, 1.19783280e-01, 9.56831331e-01, 8.13970037e-01, 9.31652985e-01, 1.66173032e-01, 7.75643951e-01, 8.18217188e-01, 4.09157394e-01, 8.79681086e-02, 6.99699330e-02, 2.83830851e-01, 7.86130899e-01, 3.07302677e-01, 3.22515094e-02, 9.80766333e-02, 1.51922811e-01, 8.32841735e-01, 2.02950643e-01, 1.75467749e-01, 5.89299014e-01, 5.68587858e-03, 1.39731373e-01, 1.24098989e-01, 5.86061757e-01, 8.02951197e-01, 6.75112152e-01, 6.12925551e-01, 9.12879475e-01, 7.82870538e-01, 6.11066659e-01, 9.47182887e-01, 6.80091177e-01, 6.81897755e-01, 3.87255875e-01, 4.41531095e-01, 5.42682340e-01, 1.95066282e-01, 3.16258113e-01, 5.14728172e-03, 3.40401462e-01, 2.28636839e-02, 4.33015231e-01, 3.03242951e-01, 5.42987921e-01, 8.32049919e-01, 3.83077540e-01, 1.88950060e-01, 6.27404840e-01, 3.94731344e-02, 5.83142355e-01, 7.82142788e-01, 2.02021237e-01, 1.23715269e-01, 2.55198190e-01, 8.94870550e-01, 8.43040034e-01, 7.47240846e-01, 4.43658215e-02, 8.04898551e-01, 9.89072353e-01, 9.77804925e-01, 9.81129660e-02, 2.44719944e-01, 3.02711336e-03, 3.80710344e-01, 1.60408477e-01, 4.63529128e-01, 5.19773717e-01, 8.07049452e-01, 1.98771956e-01, 4.08069871e-01, 7.66782859e-01, 8.24021470e-01, 3.34993078e-01, 6.73897010e-01, 6.82030113e-01, 6.40430285e-02, 5.69347368e-01, 9.87007092e-01, 1.15274348e-01, 5.81740053e-01, 7.80356264e-01, 3.49451659e-01, 4.03704918e-01, 3.24340246e-02, 9.90327779e-01, 1.06791152e-01, 2.14286294e-01, 7.38744167e-01, 5.83228260e-01, 6.43962950e-01, 7.44460361e-02, 1.93628960e-01, 8.70376105e-01, 8.25728163e-01, 1.11803702e-01, 8.40814777e-01, 1.59450982e-02, 9.63558173e-01, 5.50037693e-01, 7.53872701e-01, 8.29221505e-01, 8.45279861e-01, 2.97387519e-01, 5.51557575e-01, 7.44227389e-01, 5.23902096e-01, 7.98020416e-01, 4.34923321e-01, 9.16450551e-03, 1.66864269e-02, 4.93139209e-01, 8.55000097e-01, 5.80304322e-01, 9.74019598e-02, 2.06656457e-01, 7.24966389e-01, 5.17073571e-01, 9.35663484e-01, 6.82199207e-01, 1.69767399e-01, 5.27252966e-01, 1.06473376e-03, 8.66622110e-01, 5.85915011e-02, 8.12960901e-01, 9.83484245e-01, 1.16855643e-01, 6.50726322e-01, 1.25799904e-01, 2.40470666e-01, 6.80206504e-01, 1.45278891e-02, 8.00847142e-01, 6.66187626e-01, 5.57788910e-01, 4.40809352e-01, 9.37200525e-01, 9.08202290e-01, 4.44886373e-01, 6.03280664e-02, 8.98620097e-01, 6.24617930e-01, 9.74036582e-01, 1.89601224e-01, 6.39456514e-01, 4.77065186e-01, 5.86620526e-01, 3.30636576e-01, 8.54011536e-01, 4.49403136e-01, 1.02266611e-01, 7.28190662e-01, 5.55832590e-01, 4.18524645e-01, 5.13908615e-01, 9.96527286e-01, 4.51185336e-01, 8.36663269e-01, 7.28871667e-01, 9.68500356e-01, 4.28032629e-01, 8.69881406e-01, 1.19385650e-01, 7.89386210e-01, 8.39569885e-01, 7.63087943e-01, 3.51422633e-01, 8.40328958e-01, 8.61756543e-01, 9.84665318e-01, 8.88819990e-01, 9.69133428e-01, 6.23491368e-01, 9.61890650e-01, 7.16762690e-01, 5.70940615e-01, 9.94248706e-01, 7.94947572e-01, 1.99126206e-01, 4.31385886e-02, 2.68482290e-01, 6.40736673e-01, 8.54765815e-02, 3.67039309e-01, 3.26010501e-01, 3.31722907e-01, 7.31884555e-01, 9.90822544e-01, 9.41828893e-01, 8.07328496e-01, 8.13791016e-01, 4.97748364e-01, 6.71719644e-02, 6.70904177e-02, 4.10981293e-01, 4.67987220e-01, 3.11628400e-01, 7.03707702e-01, 1.08539104e-01, 6.06787994e-01, 5.13824034e-01, 3.49622849e-01, 5.80670816e-01, 1.98096694e-01, 7.84749101e-01, 1.30770721e-01, 8.27222607e-01, 2.57366444e-02, 6.65935246e-01, 8.99407887e-01, 9.64235577e-01, 3.36433410e-01, 8.40901427e-01, 9.51936341e-01, 4.74109200e-01, 4.34505061e-01, 3.50788946e-01, 6.75097151e-01, 4.02644902e-01, 9.49777430e-01, 8.06483520e-01, 6.94510529e-01, 1.38469763e-01, 6.28637034e-01, 4.22554214e-01, 3.55256889e-01, 8.92862091e-01])
    • (position)
      float64
      counts
      1.438, 2.850, ..., 0.039, 0.086
      σ = 1.817, 2.580, ..., 2.094, 2.959
      Values:
      array([1.43844659e+00, 2.85027760e+00, 3.30455560e+00, 3.31103694e+00, 3.52438520e+00, 1.95732864e+00, 2.39147233e+00, 2.77746193e+00, 4.21926490e+00, 4.27514400e+00, 1.18996708e+00, 3.09628294e+00, 4.04129246e+00, 1.60684681e+00, 3.80616357e+00, 7.14651965e-01, 2.42441241e+00, 1.95259504e+00, 1.72530752e+00, 3.85889184e+00, 1.28591848e+00, 6.88337690e-01, 3.18214255e+00, 1.38534252e+00, 3.35129816e+00, 3.56386283e+00, 2.28261509e+00, 2.89308338e+00, 1.27921398e+00, 2.39918583e+00, 1.37393552e+00, 4.03725416e-01, 1.97368566e-01, 3.54653071e-02, 9.28051168e-01, 2.56092854e+00, 4.14929201e+00, 2.72279650e+00, 3.21661407e-01, 2.49323142e+00, 1.51206538e+00, 1.29422733e+00, 1.21744251e+00, 1.56216059e+00, 1.93228166e+00, 1.20553884e+00, 1.81864967e+00, 1.68469449e+00, 4.22573266e+00, 1.18021083e+00, 1.99145583e+00, 3.40639229e+00, 5.87780139e-01, 1.72676243e+00, 7.27975972e-01, 2.65406478e+00, 3.01632459e+00, 1.42771159e+00, 2.41765528e+00, 3.39839363e+00, 7.82957944e-01, 6.05035320e-01, 1.05013143e+00, 2.86789815e+00, 1.13824874e+00, 3.05789880e+00, 1.99009595e+00, 2.52408942e+00, 1.03202676e-02, 3.23378469e+00, 4.20610214e-01, 2.49470124e+00, 3.31694454e+00, 1.20804160e+00, 2.31639424e+00, 4.28413759e+00, 3.40518091e+00, 2.69914270e+00, 3.43675441e+00, 2.34815194e+00, 1.26497412e+00, 2.20354560e+00, 1.10190342e+00, 3.97151783e+00, 1.00812849e+00, 3.14201216e+00, 2.45288238e+00, 1.18815231e+00, 3.47669899e+00, 2.46750126e+00, 4.01412385e+00, 1.71379076e+00, 1.74344402e+00, 3.60154453e+00, 5.86782049e-01, 1.30832332e+00, 2.58628385e+00, 3.21242540e+00, 2.52230904e+00, 4.01718884e+00, 2.67454658e+00, 3.65030011e+00, 7.90991299e-01, 6.37979755e-02, 1.63327798e+00, 2.48945713e-01, 1.48612689e+00, 1.33032307e+00, 9.96427177e-01, 2.87953891e-01, 6.11719177e-01, 1.85767673e-01, 1.42875719e+00, 2.65621361e-01, 1.32342754e+00, 1.02260547e+00, 7.88238476e-01, 1.40694323e+00, 1.10600654e-01, 4.20762102e-01, 8.42051810e-01, 1.42080217e+00, 5.73055151e-01, 9.23349956e-01, 1.47869169e+00, 7.50318550e-02, 1.60049406e+00, 6.37896804e-01, 6.89410560e-01, 1.90428399e+00, 1.76025519e+00, 4.33120261e-01, 6.76921406e-02, 1.66474542e+00, 4.27431156e-01, 1.62510429e+00, 8.81748360e-01, 7.18575614e-01, 1.45120951e+00, 6.46554532e-01, 1.57859213e+00, 1.91313773e+00, 5.67334302e-01, 1.25624439e+00, 5.78335059e-01, 1.72444294e+00, 7.45393950e-01, 1.43565615e+00, 3.32881828e-01, 1.67037841e-01, 1.99109448e+00, 1.89779723e+00, 1.02031585e+00, 1.67732973e+00, 1.42821453e+00, 1.25021560e+00, 8.61564004e-01, 1.55171789e+00, 1.05347964e+00, 4.62360649e-01, 1.73877269e+00, 1.01162034e+00, 1.51938517e+00, 1.77446146e+00, 1.78524857e+00, 3.43779682e-01, 1.46133349e+00, 1.56416271e+00, 1.58448662e+00, 7.83057614e-03, 6.14496989e-01, 1.93517901e+00, 1.68300776e-02, 2.01361424e+00, 7.46108577e-01, 1.39323892e+00, 1.02764065e+00, 1.96254935e+00, 1.67210902e+00, 3.88820652e-01, 1.31714717e+00, 6.08087869e-01, 1.29046576e+00, 1.92234935e+00, 1.15504365e+00, 1.05408565e+00, 3.21999275e-01, 5.11806291e-01, 9.38601737e-01, 1.65932798e+00, 1.56850242e+00, 2.34568880e-01, 3.33714619e-01, 6.46037506e-01, 1.19370254e+00, 1.48960229e+00, 9.08085423e-01, 1.29104958e+00, 1.09162458e+00, 1.51721187e+00, 7.03934052e-02, 1.47214604e+00, 7.41008389e-01, 4.95064412e-01, 1.19427290e+00, 8.56195138e-01, 1.16071499e+00, 2.01976960e+00, 3.17865746e-01, 1.69423905e+00, 1.81878445e+00, 9.79943391e-01, 1.32860180e+00, 1.50339466e+00, 5.03477625e-01, 4.00448590e-01, 8.60138852e-01, 1.28897660e+00, 8.73732285e-01, 9.58114663e-01, 1.52156974e+00, 1.80942769e+00, 1.90161201e+00, 6.37116684e-01, 1.91933604e+00, 1.59802566e+00, 6.31265747e-01, 1.10730274e+00, 1.70320682e+00, 5.87363963e-01, 1.25639809e+00, 5.53779846e-01, 6.79934353e-01, 9.59191201e-02, 1.42099008e-01, 5.17349920e-02, 4.52160043e-01, 2.97604911e-01, 2.27229743e-01, 6.90810038e-02, 9.84470447e-02, 6.82252623e-02, 3.69739310e-01, 5.21042804e-01, 3.38821525e-01, 1.99131021e-01, 5.35724772e-01, 3.31619985e-01, 2.24628968e-01, 3.54052503e-01, 3.81560654e-01, 6.10376645e-01, 6.01258850e-01, 7.08900097e-02, 2.13126985e-01, 6.79730167e-02, 5.85574202e-01, 5.74297851e-01, 2.76500187e-01, 5.86512203e-01, 2.00957470e-01, 5.38729968e-01, 3.35703114e-01, 6.19053747e-01, 2.94760882e-01, 5.82657158e-01, 5.21486238e-01, 1.72096033e-01, 3.01010508e-01, 4.61437732e-01, 2.86857998e-01, 3.15445906e-01, 1.30743477e-01, 1.29372865e-01, 4.43058901e-02, 4.90660645e-01, 3.33820885e-01, 9.72774917e-02, 3.51506375e-01, 3.80098635e-02, 2.91225118e-01, 5.63888649e-01, 2.21245041e-01, 2.27522123e-01, 2.86857037e-01, 5.80390017e-01, 4.74998803e-01, 4.24343212e-01, 6.10187849e-02, 2.69888828e-01, 7.68339211e-02, 2.09492288e-01, 5.76929683e-01, 4.07033816e-01, 1.78961711e-01, 1.32660919e-01, 1.90914381e-01, 6.54793432e-01, 9.46205285e-02, 4.17214990e-01, 2.33819919e-01, 2.79777828e-02, 5.60245989e-01, 4.60015952e-01, 2.11789166e-01, 1.87943906e-02, 2.26831844e-01, 1.15236385e-01, 2.16023332e-01, 5.63864581e-01, 2.02018104e-01, 1.11500478e-01, 2.31990009e-01, 9.06703873e-02, 2.24363653e-01, 6.29753909e-01, 8.13983203e-02, 5.42294401e-01, 2.18797797e-01, 3.18223890e-01, 5.67890825e-01, 2.20956980e-01, 2.74690806e-02, 1.22812318e-01, 5.48186760e-01, 3.52303833e-01, 4.20836770e-01, 3.34513310e-02, 8.53865260e-02, 5.83594078e-01, 2.18469783e-01, 3.43483192e-01, 2.42533057e-01, 3.33873532e-02, 5.22512849e-02, 4.01384066e-01, 3.52554730e-01, 1.11387776e-02, 7.58756752e-02, 4.09163057e-02, 5.20558978e-01, 4.44935903e-01, 3.49377527e-01, 2.96955242e-01, 4.74756287e-02, 9.70689619e-02, 2.71416304e-01, 5.52440112e-01, 2.93842440e-02, 2.53012055e-01, 5.56547635e-01, 2.10516147e-01, 5.86233099e-01, 5.94716593e-01, 1.90052108e-01, 2.50478578e-01, 1.37832566e-01, 3.29794934e-01, 2.59900480e-01, 2.75347612e-01, 2.35471815e-01, 7.78899989e-02, 3.29524057e-01, 5.30966405e-01, 4.41696766e-01, 8.29187389e-02, 5.24615958e-02, 8.43084781e-02, 1.16246002e-01, 7.50298270e-02, 3.45114522e-02, 7.53256532e-02, 1.60645490e-02, 3.23454174e-02, 1.54598957e-02, 6.61248826e-03, 3.07075510e-02, 4.53068923e-02, 2.39332773e-02, 9.26032584e-02, 5.86834448e-02, 9.76661587e-02, 9.76670248e-02, 5.86934823e-02, 2.59019133e-02, 2.99833967e-02, 5.85658812e-02, 8.85923910e-02, 4.87078324e-03, 2.11790997e-02, 6.28670753e-02, 5.81487243e-02, 8.82553047e-02, 5.33392823e-02, 8.63361754e-02, 1.22930813e-02, 2.08672960e-02, 5.00826395e-04, 3.22401955e-02, 1.11946625e-01, 3.29236258e-02, 1.07347426e-01, 3.11973008e-02, 5.10147367e-02, 1.13154836e-01, 9.05505423e-02, 2.76909055e-02, 5.51918900e-02, 1.18284446e-01, 6.77136451e-02, 7.11776489e-02, 8.79947389e-02, 7.06192385e-02, 4.84644678e-02, 9.42524268e-02, 8.76893604e-02, 1.06731675e-01, 8.07883621e-02, 1.07449272e-01, 2.04517605e-02, 1.10744022e-01, 8.10336409e-02, 1.18368144e-01, 5.10898847e-02, 4.97157314e-02, 6.78983317e-02, 6.36769915e-02, 1.06278860e-01, 5.56780815e-02, 6.18674523e-02, 2.06585225e-02, 1.23777821e-01, 1.04649297e-01, 9.40597464e-02, 8.76590608e-02, 9.92750602e-02, 6.06657593e-02, 7.93371995e-04, 1.01886678e-01, 1.01846654e-01, 7.52980435e-02, 2.16629346e-02, 1.07211523e-01, 7.80252455e-02, 1.15130762e-01, 1.03027163e-02, 1.02784607e-01, 3.41904710e-03, 9.29304750e-03, 9.74945643e-02, 5.51936949e-02, 5.28097808e-02, 7.05159500e-02, 1.75321775e-02, 7.57275753e-02, 2.81233394e-02, 4.15933259e-02, 1.07502698e-02, 3.49383323e-02, 3.32534733e-02, 4.07426350e-02, 9.06016099e-02, 4.09834364e-02, 7.52890402e-02, 4.17394313e-02, 7.44990266e-02, 1.28700103e-02, 2.25413728e-02, 6.04438607e-02, 2.35158675e-02, 7.49930030e-02, 3.81763738e-02, 6.35592406e-02, 8.34920594e-02, 1.02658492e-01, 9.33532592e-03, 2.26093836e-02, 2.01441841e-03, 1.41182468e-02, 8.89456298e-02, 5.27597538e-03, 1.12700509e-02, 4.35329092e-02, 8.98903287e-02, 1.11652612e-01, 7.65313625e-02, 1.37459236e-02, 1.16211616e-02, 7.71983048e-02, 4.46776879e-04, 8.34021029e-02, 5.46513146e-03, 6.84259900e-02, 3.16508581e-02, 5.76401149e-02, 3.03963975e-02, 6.33586063e-02, 5.43249067e-02, 5.90028616e-02, 3.31427164e-02, 8.31712962e-02, 1.99549923e-02, 7.69206062e-02, 6.32520036e-02, 2.91173607e-02, 2.68773026e-03, 5.81963716e-02, 5.64686969e-02, 7.27539780e-02, 6.07135737e-02, 9.46481594e-03, 2.93777874e-02, 1.83615587e-02, 6.89172269e-02, 8.80426287e-02, 6.73877372e-02, 7.86476262e-02, 3.64549596e-03, 6.50586899e-02, 8.71564863e-02, 1.89854733e-02, 9.02485102e-02, 4.68330011e-02, 7.35335198e-02, 3.74233129e-02, 1.58808715e-03, 5.10960272e-02, 3.04834587e-02, 3.67434584e-02, 8.83689631e-02, 1.25767638e-02, 1.06390214e-02, 1.10652819e-02, 7.26251385e-02, 8.84023467e-02, 3.43825824e-02, 5.62414268e-02, 1.31881568e-03, 2.15861991e-02, 3.42414333e-04, 5.92656890e-03, 9.03681564e-02, 7.39966288e-02, 4.12860482e-02, 8.10407681e-02, 5.20766254e-02, 5.03669728e-02, 9.16542074e-02, 1.33642581e-02, 1.33539563e-02, 7.88851516e-02, 2.09202755e-02, 1.07576311e-02, 8.00587847e-02, 6.11859571e-02, 8.48838888e-02, 1.50662815e-02, 6.30255622e-03, 7.00408200e-02, 6.07891400e-02, 2.96008620e-02, 3.47793882e-02, 2.44991887e-02, 9.26026575e-02, 2.32751083e-02, 4.56714261e-02, 5.88580186e-02, 5.67523883e-02, 6.08648427e-02, 9.10707535e-02, 9.67425920e-03, 6.75276731e-02, 3.08398443e-02, 3.56310598e-03, 7.87967163e-02, 8.70078418e-02, 4.08318249e-03, 8.01675958e-02, 2.96749210e-02, 1.21782273e-02, 8.59695261e-02, 6.01380936e-02, 5.94470744e-02, 2.30306226e-02, 7.73651261e-02, 3.59978882e-02, 4.41019845e-02, 4.21564751e-02, 6.31772369e-04, 9.03051523e-02, 1.18872662e-02, 4.89348115e-02, 3.81867280e-02, 8.62325233e-02, 3.58795275e-03, 2.12119770e-02, 4.28315653e-03, 4.10713321e-02, 1.01283914e-02, 7.22546041e-02, 9.45078143e-02, 5.62602855e-02, 8.10826743e-02, 8.03167418e-02, 6.69254413e-02, 6.64546315e-03, 2.06148426e-02, 6.95893661e-02, 7.48601544e-03, 3.86615712e-02, 8.62764884e-02])

      Variances (σ²):
      array([3.30262262, 6.65522802, 8.01266494, 7.77267295, 8.28175707, 4.52386799, 5.22224176, 6.63697722, 9.5062045 , 9.2434808 , 2.89528257, 7.305406 , 9.40899597, 3.80218957, 9.12674176, 1.57605545, 5.24734738, 4.7706545 , 3.95653183, 9.14575595, 2.97291337, 1.57450156, 7.07784007, 3.26433946, 8.14113019, 7.82036507, 4.98456708, 6.4440704 , 3.0228115 , 5.23333701, 3.30420684, 0.98067535, 0.42948852, 0.08353648, 2.17008665, 5.76890075, 9.40962856, 6.0147479 , 0.78849923, 5.71388317, 3.42004652, 3.12718545, 2.98544299, 3.37283945, 4.62374153, 2.61679088, 4.13881604, 4.03530364, 9.38475237, 2.61149938, 4.62341291, 7.64334777, 1.35196407, 4.22835542, 1.77620037, 6.47913173, 6.80866633, 3.30532827, 5.73506576, 8.10561598, 1.8883395 , 1.34693041, 2.35648822, 6.40622815, 2.69961755, 7.48611118, 4.88122956, 5.67718879, 0.02493251, 7.128154 , 0.97306386, 5.93304751, 7.82077658, 2.80580661, 5.54360282, 9.99517543, 7.93746033, 6.00182426, 7.62699182, 5.27944968, 2.73620894, 4.80630555, 2.48039083, 9.08006725, 2.28953181, 7.18854662, 5.41172438, 2.83462 , 7.7811284 , 5.69955387, 8.78130321, 3.78465241, 4.17414043, 8.80644055, 1.34853847, 3.14913882, 6.07316939, 7.09458921, 5.85865614, 9.58952314, 6.26926405, 8.05251862, 1.83330265, 0.15522957, 7.81225417, 1.29306093, 7.15997911, 6.83062279, 5.19290323, 1.43331442, 3.19051595, 0.91697987, 6.96645394, 1.347575 , 6.16961071, 4.77792257, 3.79654508, 6.86434155, 0.56261938, 2.09986239, 4.16980297, 7.08836156, 2.77102617, 4.81266751, 7.32675533, 0.37043898, 8.45686475, 3.25781693, 3.64760937, 9.11931629, 8.86476758, 2.26735043, 0.34905232, 8.28314938, 2.05458868, 7.64801648, 4.53831129, 3.53664092, 7.15892311, 3.04654524, 8.12637799, 9.30483793, 2.97373192, 6.23677623, 2.9826347 , 8.51146378, 3.70290938, 7.36032491, 1.65910479, 0.80087496, 9.86656238, 8.93064495, 5.32456723, 8.75767761, 7.02411744, 6.47622297, 4.07221025, 7.49902623, 5.04254516, 2.37584119, 8.84277267, 5.08860084, 7.59701032, 8.3293101 , 8.77198657, 1.6219669 , 6.83192652, 7.64777817, 7.74101713, 0.03824569, 3.12635353, 9.40487769, 0.08709328, 9.84774338, 3.71348858, 7.32126146, 5.37905926, 9.347311 , 7.93088227, 1.83367837, 6.36084899, 2.94280402, 6.49964546, 9.44546187, 5.55159855, 4.94394653, 1.51370414, 2.39883558, 4.51152454, 8.03151757, 7.34226645, 1.14978585, 1.60931279, 3.31804145, 5.61874893, 7.57085746, 4.36317792, 6.36758475, 5.29948311, 7.85082507, 0.33450535, 7.21643395, 3.67744981, 2.35793808, 5.94211476, 4.14140736, 5.43214577, 9.89031738, 1.58905883, 8.80587132, 9.36972743, 4.68622848, 6.8114246 , 7.07982283, 2.34706112, 1.87281516, 4.48722539, 6.4045007 , 4.61677814, 5.00959841, 8.04138583, 8.6213699 , 8.99265849, 3.33723024, 9.57843646, 7.9211029 , 3.33378674, 5.76493602, 8.05403987, 2.80594122, 5.985466 , 2.81558683, 3.41169957, 1.49518292, 2.17206628, 0.83836185, 6.69719937, 4.49632109, 3.76540583, 1.05815246, 1.55440559, 1.02971303, 6.12911508, 7.72059576, 5.14505418, 3.03555791, 8.305308 , 5.02537359, 3.32052819, 5.93584632, 5.64471956, 9.27416406, 9.73991012, 1.08441433, 3.34458335, 1.04683229, 9.77874439, 8.49696755, 4.36887898, 9.1227968 , 3.1896419 , 9.01635246, 5.09312079, 9.39687005, 4.76680717, 9.22398624, 8.65453016, 2.85026867, 4.61843757, 7.48290036, 4.71939608, 5.22327544, 2.15439207, 2.00247063, 0.68522163, 7.91843299, 5.39479573, 1.44240174, 5.52992422, 0.56178401, 4.4712712 , 8.92857173, 3.69416815, 3.41459144, 4.6982063 , 9.11988289, 7.90180308, 6.73680329, 0.91610428, 4.05016781, 1.14185204, 3.18776198, 8.63491783, 6.35109682, 2.86457659, 2.13502421, 2.88788392, 9.94725158, 1.39971396, 6.42868334, 3.51866786, 0.41383885, 8.59707197, 7.39272554, 3.24018366, 0.30235453, 3.44900946, 1.77140601, 3.46704568, 9.14466179, 3.05757288, 1.6632739 , 3.49471576, 1.35896527, 3.66422346, 9.33935046, 1.22453001, 9.01630149, 3.40426841, 4.80072146, 9.35845928, 3.43112577, 0.43239481, 2.05223842, 8.61643947, 5.45037588, 6.30053023, 0.56007483, 1.26409779, 9.36280096, 3.64103638, 5.28768751, 3.75377696, 0.53121696, 0.80662855, 6.68954392, 5.66896144, 0.18410822, 1.20858302, 0.65653921, 8.08962987, 6.68542281, 5.59681523, 4.94582806, 0.77284848, 1.55381162, 4.25060989, 8.48222664, 0.44212691, 3.85455382, 9.15680365, 3.24317723, 9.47753559, 9.4250678 , 2.92597252, 3.94165762, 2.25161699, 5.09016916, 4.08812632, 4.38408653, 3.51220958, 1.25336886, 5.47239283, 8.10775164, 6.63606624, 1.37824054, 4.12741601, 7.33930554, 9.09163662, 6.64096316, 2.94342337, 5.97027457, 1.34462225, 2.75770119, 1.31461562, 0.53639439, 2.53830758, 3.93127136, 2.04452569, 7.8284935 , 4.83647406, 8.54592643, 8.25630246, 4.65860132, 2.18368452, 2.34519037, 5.12495036, 7.79024655, 0.40185359, 1.68829801, 5.04577451, 5.03854491, 7.45769257, 4.24339536, 7.41102339, 1.05983804, 1.77156194, 0.04266995, 2.79411161, 9.89906114, 2.91365812, 9.01286222, 2.543372 , 4.33005477, 9.55835834, 7.69306571, 2.45357493, 4.52411793, 9.88519655, 5.84882216, 6.28504486, 6.95158928, 5.71113755, 3.81518994, 7.78365427, 7.31174442, 8.6102676 , 6.93950821, 9.02936372, 1.77587068, 9.71822088, 6.5164521 , 9.47548822, 4.37168979, 4.1743776 , 5.32117988, 5.06231193, 9.15107558, 4.46755825, 4.89913405, 1.66103808, 9.90741106, 8.84810058, 7.56015036, 7.18924244, 8.32162125, 5.20089193, 0.06396207, 9.03192322, 8.42997923, 6.04216809, 1.74854662, 9.04522136, 6.75840492, 9.52610011, 0.85235032, 8.88649646, 0.29339273, 0.81590654, 8.27163718, 4.6033567 , 4.36007787, 6.10751818, 1.40911948, 6.65156449, 2.22804869, 3.38116378, 0.85094379, 2.93251354, 2.9539143 , 3.25414229, 7.11096388, 3.29009823, 6.04947501, 3.59923533, 5.9796213 , 1.01511874, 1.91514795, 4.7459582 , 1.95861497, 6.62330326, 2.99017981, 5.08586766, 7.3725722 , 8.81058907, 0.81939082, 1.97821647, 0.17263867, 1.18909758, 7.78930837, 0.41581357, 0.9358693 , 3.69755262, 7.62254464, 9.71055559, 6.34762808, 1.51295348, 1.27473373, 8.81214148, 0.04935683, 8.69988912, 0.62493069, 7.81066617, 3.20806523, 6.19981923, 3.23872558, 7.08827524, 5.85965492, 6.33963674, 3.7283044 , 9.17023875, 2.23996475, 8.68321012, 7.02464559, 3.2856178 , 0.29366421, 6.1194618 , 5.87475323, 7.75860042, 6.74317855, 1.04167075, 3.17404941, 2.10689124, 7.55540717, 9.00005955, 7.1838389 , 8.27316745, 0.40584458, 6.96899217, 9.15144212, 1.98855487, 9.40524155, 5.2601642 , 7.53581793, 4.22603017, 0.17841183, 5.47213528, 3.1344879 , 3.90490358, 9.297212 , 1.35594565, 1.13570206, 1.14780726, 8.04589157, 9.36147286, 3.52297082, 5.95662034, 0.14972975, 2.27174623, 0.03659098, 0.62496809, 9.96130659, 7.98425745, 4.58240351, 8.67219084, 5.51927162, 5.74540674, 9.90888547, 1.49925307, 1.37900571, 8.32237382, 2.32207477, 1.2174691 , 8.57720326, 6.8844385 , 9.03323254, 1.53978672, 0.68842164, 7.86970477, 6.83950091, 3.05447102, 3.71922609, 2.58071903, 9.66491651, 2.44128884, 4.67261954, 6.65933325, 6.40802521, 6.40898645, 9.28650523, 1.07012772, 7.16210568, 3.29971624, 0.38311398, 8.85165897, 9.5891067 , 0.42991174, 9.17134334, 3.34581219, 1.31150489, 9.35910023, 6.85848138, 6.04027746, 2.34971268, 8.56213665, 3.68401086, 4.92603248, 4.789074 , 0.06875273, 9.67327012, 1.36443178, 5.16419258, 4.34520859, 9.28616807, 0.36861229, 2.35487992, 0.43884908, 4.64737965, 1.05527191, 8.11319014, 9.99201117, 6.08412878, 8.82753635, 8.41809173, 6.78423584, 0.69144464, 2.09445342, 7.35078956, 0.83643766, 4.3866077 , 8.75578401])

Binning#

scipp.bin actually reorders data and meta data such that all data contributing to a bin is in a contiguous block. Binning along multiple dimensions is supported. Of the three options it is the only solution that supports modifying data in the grouped/binned layout. A variety of operations on such binned data is available. Limitations are:

  • Requires copying and reordering the input data and can thus become expensive.

In the above example the 'y' information is dropped by hist and groupby, but bin preserves it:

[8]:
binned = table.bin(x=xbins)
binned.values[0]
[8]:
Show/Hide data repr Show/Hide attributes
scipp.DataArray (4.88 KB out of 157.50 KB)
    • position: 116
    • x
      (position)
      float64
      m
      0.013, 0.007, ..., 0.019, 0.007
      Values:
      array([0.01341082, 0.00674854, 0.00124212, 0.01605677, 0.0076007 , 0.00012884, 0.02074027, 0.01252309, 0.01388511, 0.02380089, 0.00323959, 0.02441797, 0.0104041 , 0.00486334, 0.00155994, 0.01850965, 0.00224517, 0.00858542, 0.00706852, 0.01666857, 0.01511133, 0.01507182, 0.0043397 , 0.00127773, 0.01982551, 0.00241375, 0.02369028, 0.0055294 , 0.01103775, 0.0199403 , 0.01862933, 0.0050892 , 0.02333499, 0.02308278, 0.01282285, 0.00924493, 0.010898 , 0.02150245, 0.01847693, 0.02186651, 0.01770097, 0.02196477, 0.0186333 , 0.00529771, 0.00454003, 0.01319337, 0.01711278, 0.01244405, 0.02197087, 0.02140273, 0.00236163, 0.02475197, 0.00075598, 0.01406825, 0.01782322, 0.00539831, 0.01350491, 0.00065497, 0.00488585, 0.00461248, 0.00937401, 0.00018565, 0.01206347, 0.02266198, 0.01184596, 0.00739731, 0.015748 , 0.02086287, 0.00563051, 0.00840498, 0.02204037, 0.00900532, 0.0110072 , 0.02150124, 0.02105368, 0.02058015, 0.00620351, 0.00747785, 0.01630046, 0.0216419 , 0.00020191, 0.00666018, 0.02280237, 0.01717417, 0.01844675, 0.01905506, 0.00673875, 0.02500152, 0.0086278 , 0.02042661, 0.00654179, 0.00832215, 0.01044455, 0.01814629, 0.01923764, 0.00550433, 0.00162677, 0.00172054, 0.000244 , 0.02156317, 0.01760236, 0.01799563, 0.02516493, 0.00034955, 0.00613472, 0.02302928, 0.00187485, 0.0108025 , 0.02110716, 0.01602091, 0.0038261 , 0.01239692, 0.0224797 , 0.00344897, 0.01927919, 0.00656931])
    • y
      (position)
      float64
      m
      0.413, 0.829, ..., 0.469, 0.290
      Values:
      array([0.41345108, 0.82897621, 0.46554662, 0.07455039, 0.98275361, 0.74464154, 0.48513071, 0.20889904, 0.33747454, 0.63364914, 0.4229297 , 0.85925963, 0.52753899, 0.44873265, 0.15440453, 0.93773643, 0.08830422, 0.30301302, 0.83609062, 0.76597774, 0.48266168, 0.44067943, 0.06925309, 0.7343824 , 0.36587507, 0.05865598, 0.69993495, 0.20074869, 0.21094638, 0.42018179, 0.16155301, 0.77697431, 0.60252769, 0.44565102, 0.17597423, 0.66174335, 0.77067752, 0.50200245, 0.37615778, 0.78620166, 0.8652417 , 0.056556 , 0.79807656, 0.4297381 , 0.86076864, 0.73706236, 0.42526774, 0.21733209, 0.4932889 , 0.30234911, 0.94537933, 0.36665451, 0.60643431, 0.47230535, 0.41791087, 0.57016903, 0.31357162, 0.48247112, 0.09334738, 0.62063553, 0.79493813, 0.72510023, 0.11778181, 0.63999281, 0.94680245, 0.68774379, 0.75831833, 0.47189809, 0.82405599, 0.17731012, 0.13946922, 0.41721169, 0.04435025, 0.20632256, 0.06783375, 0.46350104, 0.08642263, 0.04414839, 0.92570305, 0.4470891 , 0.08991347, 0.37321106, 0.64695499, 0.24679294, 0.61616705, 0.15716846, 0.39417621, 0.24161846, 0.35488123, 0.2632197 , 0.41949406, 0.37163684, 0.61183995, 0.1713582 , 0.01715131, 0.29006211, 0.9945185 , 0.08634312, 0.5459315 , 0.08618554, 0.60988714, 0.30221768, 0.96177201, 0.05721328, 0.1767491 , 0.08918606, 0.25157565, 0.29989562, 0.84681572, 0.08214064, 0.9745338 , 0.33464195, 0.11677853, 0.12732173, 0.46932359, 0.28966363])
    • (position)
      float64
      counts
      2.446, 1.161, ..., 0.630, 1.976
      σ = 1.617, 1.096, ..., 0.833, 1.429
      Values:
      array([2.44570777, 1.16090923, 0.06266408, 5.95115874, 3.64890119, 3.09007708, 7.5612098 , 7.69820324, 6.5318802 , 0.15862316, 6.73251861, 2.81059989, 6.42011369, 5.6297167 , 1.13321561, 5.28190475, 1.16651046, 7.79700216, 5.96095298, 1.97504934, 4.65909924, 5.07132831, 6.49572719, 5.05803414, 2.00173158, 0.83290239, 4.43485253, 3.74768444, 1.52384465, 2.12462201, 9.09020427, 8.68390065, 7.59934939, 1.94707225, 6.08550154, 6.54187096, 1.26421859, 4.5928975 , 6.53765871, 7.57110238, 2.66686656, 5.29084415, 3.80995808, 7.97762007, 1.52305233, 5.99746519, 4.78067259, 4.19722666, 6.52367316, 6.93345817, 4.18850991, 4.80848198, 7.27470487, 3.40009851, 2.12580659, 3.92787072, 6.09239805, 7.69166445, 7.68611104, 4.41537743, 7.94531387, 1.10516574, 5.92863204, 4.83610691, 1.85826085, 2.88009334, 8.67373583, 0.88732713, 8.23256253, 3.4045493 , 6.45460458, 7.72748629, 6.13380891, 8.44275556, 0.77032232, 8.01049228, 8.23500921, 3.51442435, 3.2135056 , 8.48296103, 1.20877359, 6.24293864, 6.7540939 , 6.2174331 , 7.72676727, 8.34134053, 9.09641432, 2.92274492, 7.11842399, 5.35840189, 7.3790111 , 4.92356456, 1.24822991, 3.56965792, 8.84325644, 9.42293369, 9.00271566, 3.63143893, 4.26712386, 6.03682125, 6.54720111, 7.86788312, 2.12961473, 8.04662996, 3.04697145, 0.47486339, 5.47751514, 5.41326396, 2.43979608, 7.84092736, 1.39430917, 2.33612359, 8.13459031, 0.92209768, 0.62979233, 1.97577272])

      Variances (σ²):
      array([2.61532575, 1.2007498 , 0.06305447, 6.44864334, 3.79024091, 3.09206832, 8.38741636, 8.19564069, 7.00147183, 0.17866915, 6.84245948, 3.17557212, 6.76293055, 5.76829087, 1.14208894, 5.7940702 , 1.17967934, 8.13899249, 6.1753957 , 2.14670952, 5.02476548, 5.46826779, 6.63821495, 5.09045161, 2.21032629, 0.84301538, 4.99254471, 3.85274228, 1.61030766, 2.34736963, 9.97761428, 8.9077064 , 8.53979984, 2.18527296, 6.48844806, 6.85136482, 1.33501726, 5.11421205, 7.17041643, 8.44581646, 2.91365722, 5.90501315, 4.18197944, 8.19175934, 1.55802121, 6.40644013, 5.20773569, 4.46667479, 7.2811728 , 7.71658842, 4.23826168, 5.44197086, 7.30225468, 3.64787801, 2.32394781, 4.03533385, 6.51799187, 7.71689487, 7.87618911, 4.51838985, 8.32657615, 1.1061921 , 6.29723619, 5.41633789, 1.97165016, 2.9886126 , 9.38431405, 0.98488817, 8.46762341, 3.55067403, 7.206588 , 8.0833809 , 6.48085149, 9.40098928, 0.85583486, 8.87868073, 8.49444166, 3.64831339, 3.48638267, 9.45240379, 1.20999453, 6.45433428, 7.5697549 , 6.77492294, 8.47333605, 9.17515449, 9.40812867, 3.31192908, 7.43222538, 5.93459521, 7.62436159, 5.13275991, 1.31514802, 3.90868595, 9.73612674, 9.68587014, 9.07624102, 3.66281396, 4.27233303, 6.72406889, 7.14955028, 8.60864713, 2.41516047, 8.06070586, 3.1418812 , 0.53281461, 5.52910424, 5.71368816, 2.71135972, 8.4948633 , 1.42123976, 2.48550925, 9.10227059, 0.93813703, 0.69352416, 2.04174759])

If we omit the call to bins.sum in the original example, we can subsequently apply another histogramming or binning operation to the data:

[9]:
binned = binned.bin(y=100)
binned
[9]:
Show/Hide data repr Show/Hide attributes
scipp.DataArray (220.91 KB)
    • x: 39
    • y: 100
    • x
      (x [bin-edge])
      float64
      m
      0.0, 0.026, ..., 0.974, 1.0
      Values:
      array([0. , 0.02564103, 0.05128205, 0.07692308, 0.1025641 , 0.12820513, 0.15384615, 0.17948718, 0.20512821, 0.23076923, 0.25641026, 0.28205128, 0.30769231, 0.33333333, 0.35897436, 0.38461538, 0.41025641, 0.43589744, 0.46153846, 0.48717949, 0.51282051, 0.53846154, 0.56410256, 0.58974359, 0.61538462, 0.64102564, 0.66666667, 0.69230769, 0.71794872, 0.74358974, 0.76923077, 0.79487179, 0.82051282, 0.84615385, 0.87179487, 0.8974359 , 0.92307692, 0.94871795, 0.97435897, 1. ])
    • y
      (y [bin-edge])
      float64
      m
      0.000, 0.010, ..., 0.990, 1.000
      Values:
      array([1.66752674e-04, 1.01642985e-02, 2.01618443e-02, 3.01593901e-02, 4.01569359e-02, 5.01544817e-02, 6.01520275e-02, 7.01495733e-02, 8.01471191e-02, 9.01446649e-02, 1.00142211e-01, 1.10139757e-01, 1.20137302e-01, 1.30134848e-01, 1.40132394e-01, 1.50129940e-01, 1.60127486e-01, 1.70125031e-01, 1.80122577e-01, 1.90120123e-01, 2.00117669e-01, 2.10115215e-01, 2.20112760e-01, 2.30110306e-01, 2.40107852e-01, 2.50105398e-01, 2.60102944e-01, 2.70100489e-01, 2.80098035e-01, 2.90095581e-01, 3.00093127e-01, 3.10090673e-01, 3.20088218e-01, 3.30085764e-01, 3.40083310e-01, 3.50080856e-01, 3.60078402e-01, 3.70075947e-01, 3.80073493e-01, 3.90071039e-01, 4.00068585e-01, 4.10066131e-01, 4.20063676e-01, 4.30061222e-01, 4.40058768e-01, 4.50056314e-01, 4.60053860e-01, 4.70051405e-01, 4.80048951e-01, 4.90046497e-01, 5.00044043e-01, 5.10041589e-01, 5.20039134e-01, 5.30036680e-01, 5.40034226e-01, 5.50031772e-01, 5.60029318e-01, 5.70026864e-01, 5.80024409e-01, 5.90021955e-01, 6.00019501e-01, 6.10017047e-01, 6.20014593e-01, 6.30012138e-01, 6.40009684e-01, 6.50007230e-01, 6.60004776e-01, 6.70002322e-01, 6.79999867e-01, 6.89997413e-01, 6.99994959e-01, 7.09992505e-01, 7.19990051e-01, 7.29987596e-01, 7.39985142e-01, 7.49982688e-01, 7.59980234e-01, 7.69977780e-01, 7.79975325e-01, 7.89972871e-01, 7.99970417e-01, 8.09967963e-01, 8.19965509e-01, 8.29963054e-01, 8.39960600e-01, 8.49958146e-01, 8.59955692e-01, 8.69953238e-01, 8.79950783e-01, 8.89948329e-01, 8.99945875e-01, 9.09943421e-01, 9.19940967e-01, 9.29938512e-01, 9.39936058e-01, 9.49933604e-01, 9.59931150e-01, 9.69928696e-01, 9.79926241e-01, 9.89923787e-01, 9.99921333e-01])
    • (x, y)
      DataArrayView
      binned data [len=0, len=1, ..., len=2, len=2]
      dim='position',
      content=DataArray(
                dims=(position: 5000),
                data=float64[counts],
                coords={'x':float64[m], 'y':float64[m]})

As in the 1-D example above, summing the bins is equivalent to histogramming binned data:

[10]:
binned.bins.sum().plot()
[10]:
../../_images/user-guide_binned-data_histogramming-grouping-and-binning_18_0.svg