ReferencebinCounts

<binCounts>

How many values fall in each interval between cut points

<binCounts> is a Math Operator component that renders how many of its arguments fall into each interval between the cut points given by bins: a list of counts, one per interval. Where <tally> counts values that are equal to a category, <binCounts> counts values that fall between two cut points, which is what a histogram of a continuous quantity needs.

Values outside the outermost cut points are not counted, so the counts need not sum to the number of values.

Attributes and Properties

Attributes for <binCounts>

Highlighted (3)
asList

boolean. Default value: true. Whether to render the items separated by commas (true) or with no separator (false).

numberList. The cut points, each at least as large as the one before it. n + 1 cut points define n bins.

keyword. Which end of each bin includes its cut point.

ValueDescription
left (default)Bins are [a, b), matching NumPy and the usual textbook class interval. The last bin also includes its upper cut point, so the largest value is not dropped.
rightBins are (a, b], matching R, pandas and Excel. The first bin also includes its lower cut point, so the smallest value is not dropped.
Other (5)
avoidScientificNotation

Whether to render numbers in full decimal form rather than scientific notation.

displayDecimals

Number of decimal places to display when rendering this number.

displayDigits

Number of significant digits to display when rendering this number.

displaySmallAsZero

Threshold below which numbers are displayed as zero.

padZeros

Whether to pad displayed numbers with trailing zeros to fill the requested digits/decimals.

Common to all components (9)
copy

reference. Create an independent copy of another component by reference. Enter a references a $name.

disabled

boolean. Default value: false. Whether this component is disabled and cannot be interacted with.

extend

reference. Extend another component by reference, inheriting its children and attributes. Enter a reference as $name.

fixed

Default value: false. Whether this component's value is fixed and cannot be modified.

fixLocation

boolean. Default value: false. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).

hide

boolean. Default value: false. Whether to hide this component from the rendered output.

isResponse

boolean. Default value: false. Whether this component is treated as a response for the purposes of assessment.

name

text. The name used to reference this component from elsewhere in the document.

styleNumber

integer. Default value: 1. The style number used to select this component's visual styling from the available style definitions.

Properties for <binCounts name="b">

Highlighted (1)
$b.closed

text. Which end of each bin includes its cut point.

Other (1)

[ number ]. The cut points that define the bins, in order.

Common to all components (4)
$b.doenetML

text. The DoenetML source code that produced this component.

$b.hide

boolean. Whether to hide this component from the rendered output.

$b.isResponse

boolean. Whether this component is treated as a response for the purposes of assessment.

$b.styleNumber

integer. The style number used to select this component's visual styling from the available style definitions.

Examples

Example: binning a continuous sample


Example: counting a weighted population directly

With cumulative subpopulation sizes as the cut points, right-closed bins are the subpopulations: individuals 1–30, 31–75, 76–87 and 88–147. This reaches the same counts as <searchSorted> followed by <tally>, without the intermediate list of subpopulation indices — use whichever you also want to show.

Attribute Examples

Attribute Example: bins

n + 1 cut points define n intervals. Bare numbers work as well as <number> children, and are read the way <sum> reads them, so an expression such as 1/2 falls in a bin too.


Attribute Example: closed

A value landing exactly on a cut point has to be counted on one side or the other. Left-closed, the bins are [0, 1) and [1, 2], so 1 is counted in the second. Right-closed they are [0, 1] and (1, 2], so 1 is counted in the first. Both include 0 and 2, because the outermost cut points always belong to a bin.


Property Examples

Property Example: binEdges

The cut points are readable back, so whatever displays the counts can say what interval each one covers.