BinCounts

BinCounts[{x1,x2,}]

counts the number of elements xi whose values lie in successive integer bins.

BinCounts[{x1,x2,},dx]

counts the number of elements xi whose values lie in successive bins of width dx.

BinCounts[{x1,x2,},{xmin,xmax,dx}]

counts the number of xi in successive bins of width dx from xmin to xmax.

BinCounts[{x1,x2,},{{b1,b2,}}]

counts the number of xi in the intervals [b1,b2), [b2,b3), .

BinCounts[{{x1,y1,},{x2,y2,},},xbins,ybins,]

gives an array of counts where the first index corresponds to x bins, the second to y, and so on.

Details

  • BinCounts drops elements whose values do not correspond to real numbers.
  • BinCounts[data,dx] takes the bin boundaries to be integer multiples of dx, with the first bin starting at Ceiling[Min[data]-dx,dx] and the last bin ending at Floor[Max[data]+dx,dx].
  • BinCounts[data] is equivalent to BinCounts[data,1].
  • BinCounts[data,{xmin,xmax}] is equivalent to BinCounts[data,{xmin,xmax,1}].
  • In BinCounts[data,{xmin,xmax,dx}], elements are counted in bin i when their values satisfy .
  • In the form BinCounts[data,{{b1,b2,}}], the bi at each end can be -Infinity and +Infinity.
  • If the bi do not form an increasing sequence, they are automatically sorted by BinCounts.
  • In BinCounts[data,{{b1,b2,}}], elements are counted in bin i when their values satisfy .
  • If data consists of length-n sublists, then n bin specifications must be given, and BinCounts[data,] yields an array of depth n.
  • BinCounts works with SparseArray objects.

Examples

open allclose all

Basic Examples  (3)

Count the number of elements in bins of width 1 from 0 to 10:

Count the number of elements in a sequence of ranges:

Count the number of elements in bins of a specified width:

Scope  (8)

Count squares mod 3 and 5 in two-dimensional unit bins:

Count random pairs in bins of width 0.25 in both dimensions:

Count multidimensional data in ranges:

Count data in any dimension:

Count binned data, ignoring values that are not real:

Count binned data of any precision:

Count the values of data in a time series:

The time stamps are ignored:

Count data in a SparseArray:

Applications  (1)

Visualize the density of two-dimensional data in bins:

Properties & Relations  (1)

The results from BinCounts are equivalent to the lengths of BinLists:

Possible Issues  (1)

Binning intervals are closed on the left:

Wolfram Research (2007), BinCounts, Wolfram Language function, https://reference.wolfram.com/language/ref/BinCounts.html.

Text

Wolfram Research (2007), BinCounts, Wolfram Language function, https://reference.wolfram.com/language/ref/BinCounts.html.

CMS

Wolfram Language. 2007. "BinCounts." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/BinCounts.html.

APA

Wolfram Language. (2007). BinCounts. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/BinCounts.html

BibTeX

@misc{reference.wolfram_2023_bincounts, author="Wolfram Research", title="{BinCounts}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/BinCounts.html}", note=[Accessed: 04-December-2023 ]}

BibLaTeX

@online{reference.wolfram_2023_bincounts, organization={Wolfram Research}, title={BinCounts}, year={2007}, url={https://reference.wolfram.com/language/ref/BinCounts.html}, note=[Accessed: 04-December-2023 ]}