<sampleRandomNumbers/>
<sampleRandomNumbers/>
is a Math
component that generates random numbers from a specified range of values or within a normal distribution
around a specified mean. It differs from the <selectRandomNumbers/>
component in that the
values can be altered within the document by resampling or changing one or more of the
component’s attributes. The primary application of the <sampleRandomNumbers/>
component
is for use in simulations involving random numbers.
Attributes and Properties
Attribute | Type | Values |
---|---|---|
asList = "…" | "true" "false" | |
displayDecimals = "…" | ||
displayDigits = "…" | ||
displaySmallAsZero = "…" | ||
exclude = "…" | ||
from = "…" | number | |
mean = "…" | number | |
numSamples = "…" | number | |
padZeros = "…" | ||
standardDeviation = "…" | number | |
step = "…" | number | |
to = "…" | number | |
type = "…" | text | "uniform" "discreteuniform" "gaussian" |
variance = "…" | number | |
variantDeterminesSeed = "…" | boolean | "true" "false" |
Property | Type |
---|---|
$s.from | number |
$s.mean | number |
$s.numSamples | number |
$s.standardDeviation | number |
$s.step | number |
$s.to | number |
$s.type | text |
$s.variance | number |
$s.variantDeterminesSeed | boolean |
Example: Default <sampleRandomNumbers/>
Without any attributes specified, the default sampling type
is uniform
, and the
default interval is . In this example, there are two ways to view different
samples: selecting another variant, or refreshing the page.
Example: Using a re-sampling button
Without any attributes specified, the default sampling type
is uniform
, and
the default interval is . The <callAction>
button can be used to
resample the value.
Attribute Example: numSamples
The <sampleRandomNumbers/>
component is used with the numSamples
attribute to
select multiple random values in the default interval . The default type
is uniform
.
Attribute Example: from, to
The <sampleRandomNumbers/>
component is used with the from
and the to
attributes
to modify the default selection interval. The default type
is uniform
.
Attribute Example: type = “discreteUniform”
The type
attribute of the <sampleRandomNumbers/>
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.
Attribute Example: exclude
The type
attribute of the <sampleRandomNumbers/>
component is specified
as discreteUniform
. Values can be excluded from the specified range used with
this type using the exclude
attribute.
Attribute Example: step
The type
attribute of the <sampleRandomNumbers/>
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.
Attribute Example: type = “gaussian”
The type
attribute of the <sampleRandomNumbers/>
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.
Attribute Example: gaussian with mean and variance
The type
attribute of the <sampleRandomNumbers/>
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.
Attribute Example: gaussian with mean and standardDeviation
The type
attribute of the <sampleRandomNumbers/>
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.