<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 the largest value is not dropped. |
right | Bins 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)
avoidScientificNotationWhether to render numbers in full decimal form rather than scientific notation.
displayDecimalsNumber of decimal places to display when rendering this number.
displayDigitsNumber of significant digits to display when rendering this number.
displaySmallAsZeroThreshold below which numbers are displayed as zero.
padZerosWhether 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.
fixedDefault 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.
Other (1)
$b.binEdges[ number ]. The cut points that define the bins, in order.
Common to all components (4)
$b.doenetMLtext. The DoenetML source code that produced this component.
$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.