ReferencesummaryStatistics

<summaryStatistics>

Summary statistics (mean, median, etc.) for a list of numbers.

<summaryStatistics> is a General Operator component that renders a table of statistics — mean, standard deviation, median, quartiles and the rest — for the numbers it is given, whether written out or referenced with $scores. Every statistic in the table is also a property, so a sentence can quote the same number the table shows.

Attributes and Properties

Attributes for <summaryStatistics>

Highlighted (1)

[ keyword ]. Which summary statistics to display (or "default" / "all" / "fiveNumberSummary").

ValueDescription
default (default)The default selection: mean, stdev, count, minimum, quartile1, median, quartile3, maximum.
allEvery statistic listed here.
fiveNumberSummaryThe five-number summary: minimum, quartile1, median, quartile3, maximum.
meanThe arithmetic mean of the values.
stdevThe sample standard deviation.
varianceThe sample variance.
stderrThe standard error of the mean.
countThe number of non-missing values.
minimumThe smallest value.
quartile1The first quartile (25th percentile).
medianThe median value.
quartile3The third quartile (75th percentile).
maximumThe largest value.
rangeThe maximum minus the minimum.
sumThe sum of the values.
Number display (5)
avoidScientificNotation

boolean. Default value: false. Whether to render numbers in full decimal form rather than scientific notation.

displayDecimals

integer. Default value: 2. Number of decimal places to display when rendering this number.

integer. Default value: 3. Number of significant digits to display when rendering this number.

displaySmallAsZero

number. Default value: 1e-14. Threshold below which numbers are displayed as zero.

padZeros

boolean. Default value: false. 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

boolean. 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 <summaryStatistics name="s">

Highlighted (13)

integer. The number of non-missing values.

number. The largest value.

$s.mean

number. The arithmetic mean of the values.

$s.median

number. The median value.

number. The smallest value.

$s.quartile1

number. The first quartile (25th percentile).

$s.quartile3

number. The third quartile (75th percentile).

number. The maximum minus the minimum.

$s.statisticsToDisplay

textList. Which summary statistics to display.

$s.stderr

number. The standard error of the mean.

$s.stdev

number. The sample standard deviation.

$s.sum

number. The sum of the values.

$s.variance

number. The sample variance.

Number display (5)
$s.avoidScientificNotation

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

$s.displayDecimals

integer. Number of decimal places to display when rendering this number.

$s.displayDigits

integer. Number of significant digits to display when rendering this number.

$s.displaySmallAsZero

number. Threshold below which numbers are displayed as zero.

$s.padZeros

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

Other (4)
$s.disabled

boolean. Whether this component is disabled and cannot be interacted with.

$s.fixed

boolean. Whether this component's value is fixed and cannot be modified.

$s.fixLocation

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

$s.hidden

boolean. Whether this component is hidden from the rendered output.

Common to all components (4)
$s.doenetML

text. The DoenetML source code that produced this component.

$s.hide

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

$s.isResponse

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

$s.styleNumber

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

Examples

Example: statistics of a list

The table and the sentence read from the same component, so they cannot disagree.


Example: values that are not numbers

A value that is not a number counts as missing and is left out, which is why count reports how many values were usable rather than how many were given. If nothing usable is left, count is 0 and every other statistic has no value: its cell is blank, and a reference to it reads as NaN.


Example: summarizing a simulation

The statistics are of the four counts, not of the 80 draws — so sum is the sample size and mean is how many draws an average subpopulation received. Drawing again updates both the counts and the table.


Attribute Examples

Attribute Example: statisticsToDisplay

Omit it for a standard selection. default, all and fiveNumberSummary name a set rather than excluding what sits beside them, so statisticsToDisplay="default sum" shows the standard selection and the sum. Statistics appear in a fixed order whatever order they are asked for in, so two documents showing the same set read the same way.


Attribute Example: displayDigits

displayDigits shapes how the numbers are written, in the table and in a reference to a statistic alike — a reference carries the same setting, so $rounded.mean prints 81.4 here rather than the mean in full. displayDecimals, displaySmallAsZero, padZeros and avoidScientificNotation shape them the same way and follow the same rule.

count is the exception. It is an exact tally, so it is never rounded: this table would still report 1234 observations as 1234, where three significant digits would have made them 1230.


Property Examples

Property Example: mean, count, minimum, maximum, range

Every statistic is readable this way, stdev, variance, stderr, the quartiles, median and sum included — and so are the ones the table was not asked to show: statisticsToDisplay chooses what is displayed, not what is computed, so $s.minimum and $s.maximum above are available from a table that lists neither.