<binCounts>
<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)
asListboolean. 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.
| Value | Description |
|---|---|
left (default) | Bins are [a, b), matching NumPy and the usual textbook class interval. The last bin also includes its upper cut point, so a value sitting exactly on it is counted. |
right | Bins are (a, b], matching R, pandas and Excel. The first bin also includes its lower cut point, so a value sitting exactly on it is counted. |
Number display (5)
avoidScientificNotationboolean. Default value: false. Whether to render numbers in full decimal form rather than scientific notation.
displayDecimalsinteger. Default value: 2. Number of decimal places to display when rendering this number.
displayDigitsinteger. Default value: 3. Number of significant digits to display when rendering this number.
displaySmallAsZeronumber. Default value: 1e-14. Threshold below which numbers are displayed as zero.
padZerosboolean. Default value: false. Whether to pad displayed numbers with trailing zeros to fill the requested digits/decimals.
Common to all components (9)
copyreference. Create an independent copy of another component by reference. Enter a references a $name.
disabledboolean. Default value: false. Whether this component is disabled and cannot be interacted with.
extendreference. Extend another component by reference, inheriting its children and attributes. Enter a reference as $name.
fixedboolean. Default value: false. Whether this component's value is fixed and cannot be modified.
fixLocationboolean. Default value: false. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).
hideboolean. Default value: false. Whether to hide this component from the rendered output.
isResponseboolean. Default value: false. Whether this component is treated as a response for the purposes of assessment.
nametext. The name used to reference this component from elsewhere in the document.
styleNumberinteger. 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.closedtext. Which end of each bin includes its cut point.
Number display (5)
$b.avoidScientificNotationIn developmentboolean. Whether to render numbers in full decimal form rather than scientific notation.
$b.displayDecimalsIn developmentinteger. Number of decimal places to display when rendering this number.
$b.displayDigitsIn developmentinteger. Number of significant digits to display when rendering this number.
$b.displaySmallAsZeroIn developmentnumber. Threshold below which numbers are displayed as zero.
$b.padZerosIn developmentboolean. Whether to pad displayed numbers with trailing zeros to fill the requested digits/decimals.
Other (1)
$b.binEdges[ number ]. The cut points that define the bins, in order.
Common to all components (8)
$b.disabledIn developmentboolean. Whether this component is disabled and cannot be interacted with.
$b.doenetMLtext. The DoenetML source code that produced this component.
$b.fixedIn developmentboolean. Whether this component's value is fixed and cannot be modified.
$b.fixLocationIn developmentboolean. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).
$b.hideboolean. Whether to hide this component from the rendered output.
$b.isResponseboolean. Whether this component is treated as a response for the purposes of assessment.
$b.styleNumberinteger. 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.