<selectRandomNumbers/>
<selectRandomNumbers/> is a Math
component that generates document variants by selecting random numbers from a specified range of
values or within a normal distribution around a specified mean.
Attributes and Properties
Attributes for <selectRandomNumbers>
Other (15)
asListboolean. Default value: true. Whether to render the items separated by commas (true) or with no separator (false).
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.
numberList. Values to exclude from the sample space.
number. Lower bound of the sampling range.
meannumber. Default value: 0. Mean of the sampling distribution (Gaussian).
integer. Default value: 1. How many random numbers to select.
padZerosWhether to pad displayed numbers with trailing zeros to fill the requested digits/decimals.
standardDeviationnumber. Default value: 1. Standard deviation of the sampling distribution (Gaussian).
number. Default value: 1. Step size between samples for the discrete-uniform distribution.
number. Upper bound of the sampling range.
typekeyword. Distribution from which to sample.
| Value | Description |
|---|---|
uniform (default) | Continuous uniform distribution over [from, to]. |
discreteUniform | Discrete uniform distribution over integers in [from, to]. |
gaussian | Normal (Gaussian) distribution with the specified mean and standard deviation. |
variancenumber. Default value: 1. Variance of the sampling distribution (Gaussian).
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 <selectRandomNumbers name="s">
Other (8)
$s.fromnumber. Lower bound of the sampling range.
$s.meannumber. Mean of the sampling distribution.
$s.numToSelectinteger. How many random numbers to select.
$s.standardDeviationnumber. Standard deviation of the sampling distribution.
$s.stepnumber. Step size between sample values (for discrete distributions).
$s.tonumber. Upper bound of the sampling range.
$s.typetext. Distribution from which to sample.
$s.variancenumber. Variance of the sampling distribution.
Common to all components (4)
$s.doenetMLtext. The DoenetML source code that produced this component.
$s.hideboolean. Whether to hide this component from the rendered output.
$s.isResponseboolean. Whether this component is treated as a response for the purposes of assessment.
$s.styleNumberinteger. The style number used to select this component's visual styling from the available style definitions.
Examples
Example: Default <selectRandomNumbers/>
Without any attributes specified, the default selection type is uniform, and the default interval is .
Select a new page variant from the pulldown menu at the top of the editor to see different variants of the document.
Example: Assign descriptive names to selections
Three numbers are selected. Selections can be assigned more descriptive names by defining individual components which reference the selected values.
Select a new page variant from the pulldown menu at the top of the editor to see different variants of the document.
Attribute Examples
Attribute Example: numToSelect
The <selectRandomNumbers/> component is used with the numToSelect attribute to select multiple
random values in the default interval . The default type is uniform.
Select a new page variant from the pulldown menu at the top of the editor to see different variants of the document.
Attribute Example: from, to
The <selectRandomNumbers/> component is used with the from and the to attributes to modify the
default selection interval. The default type is uniform.
Select a new page variant from the pulldown menu at the top of the editor to see different variants of the document.
Attribute Example: type = “discreteUniform”
The type attribute of the <selectRandomNumbers/> component is specified as discreteUniform.
The discreteUniform selection generates values from an evenly spaced range defined by the
attributes to, from, and step. If left unspecified, the default step is 1.
Select a new page variant from the pulldown menu at the top of the editor to see different variants of the document.
Attribute Example: exclude
The type attribute of the <selectRandomNumbers/> component is specified
as discreteUniform. Values can be excluded from the specified range used with this type using the exclude attribute.
Select a new page variant from the pulldown menu at the top of the editor to see different variants of the document.
Attribute Example: step
The type attribute of the <selectRandomNumbers/> component is specified as discreteUniform.
The discreteUniform selection generates values from an evenly spaced range defined by the
attributes to, from, and step. If left unspecified, the default step is 1.
Select a new page variant from the pulldown menu at the top of the editor to see different variants of the document.
Attribute Example: type = “gaussian”
The type attribute of the <selectRandomNumbers/> component is
specified as gaussian. The gaussian selection generates standard normal
variables (mean 0, variance 1). Alternatively, the mean as well as the variance
or the standardDeviation attributes may be defined.
Select a new page variant from the pulldown menu at the top of the editor to see different variants of the document.
Attribute Example: gaussian with mean and variance
The type attribute of the <selectRandomNumbers/> component is specified
as gaussian. The gaussian selection generates standard normal variables (mean 0, variance 1). In
this example, the mean and the variance are defined with attributes.
Select a new page variant from the pulldown menu at the top of the editor to see different variants of the document.
Attribute Example: gaussian with mean and standardDeviation
The type attribute of the <selectRandomNumbers/> component is specified
as gaussian. The gaussian selection generates standard normal variables (mean 0, variance 1). In
this example, the mean and the standardDeviation are defined with attributes.
Select a new page variant from the pulldown menu at the top of the editor to see different variants of the document.