Classes implementing the Transform.Discrete
interface adapt driver values to the
integer range from zero upwards. Integers
are discrete: if k is an integer then k+1 and k-1 are also integers
but intervening values such as k+0.5 are not integers. Integers never have digits right of the decimal point.
Although integers in general can be both positive and negative, the discrete
statistical distributions upon which Transform.Discrete
classes are based
consistently adopt zero as a lower bound. Also, Transform.Discrete
output
is very frequently an intermediate step on the way to selecting content from an array
or a List
, and
these structures don't cope well with negative indexing. For those applications where a negative lower bound remains necessary, it is
simple enough to incorporate an offset.
All discrete-transform names are prefixed with the word "Discrete"; the prefix was needed to distinguish
DiscreteUniform
and
DiscreteWeighted
from
ContinuousUniform
and
ContinuousWeighted
.
I thought, well the others are discrete too.
Discrete-transform ranges always begin at zero; the upper limit can be bounded or unbounded. When the upper limit is unbounded, the weights associated with range values must tail away to zero.
Listed alphabetically, the discrete transforms are:
DiscreteBinomial
is bounded
and motivated by the urn model.
It is also the discrete counterpart of ContinuousNormal
.
DiscreteNegativeBinomial
is
unbounded and motivated by the urn model.
It is also the discrete counterpart of ContinuousGamma
.
DiscretePoisson
is
unbounded and motivated by the Poisson Point Process.
DiscreteTrial
is
bounded and motivated by the urn model.
(A trial is in fact the basic action from which all
other urn-model scenarios derive.)
DiscreteUniform
is bounded.
It is also the discrete counterpart of ContinuousUniform
.
All range values are equally likely.
DiscreteWeighted
is bounded.
It is also the discrete counterpart of ContinuousWeighted
.
Each range value is associated with a user-specified weight.
DiscreteDistributionTransform
base class.
The code behind DiscreteDistributionTransform
class is presented in Listing 1
The type hierarchy for DiscreteDistributionTransform
is:
TransformBase<T
extends Number>
extends WriteableEntity
implements Transform<T>
DiscreteDistributionTransform
extends TransformBase<Integer>
implements Transform.Discrete
The abstract DiscreteDistributionTransform
class presented as Listing 1
manages an embedded DiscreteDistribution
instance.
Most, but not all, of the classes implementing the Transform.Discrete
interface subclass from DiscreteDistributionTransform
.
The DiscreteDistributionTransform
class stores its embedded
DiscreteDistribution
instance in the distribution
field. Since one subclass makes no use of this class's functonality, the distribution
field
is populated upon the first getDistribution()
call. Hence methods that reference the
distribution
field must perform their own initialization checks.
For each integer value in the application range, the DiscreteDistribution
instance maintains
an item detailing a weight (unnormalized probability) and the cumulative sum of weights up to and including the present value. The weights
define the distribution, while the cumulative sums support
DiscreteDistribution.quantile()
.
Of the methods implemented in the class, convert()
does the actual work of transforming driver-domain
values into application-range values.
© Charles Ames | Page created: 2022-08-29 | Last updated: 2022-08-29 |