DiscreteValueMap - Maple Help

Statistics

 DiscreteValueMap
 details of discrete distributions

 Calling Sequence DiscreteValueMap(X, n)

Parameters

 X - algebraic; random variable or distribution n - algebraic; point

Description

 • The DiscreteValueMap command returns technical details about the Maple implementation of discrete probability distributions.
 • Maple supports two types of probability distributions: continuous ones, which can assume a continuum of values (each individual value having probability 0), and discrete ones, which can assume a finite or countable set of values (each having positive probability). (It is possible to conceive of mixed distributions, which assume some values with positive probability and can also assume a continuum of values, but they do not occur too frequently in practice and Maple has no support for them.)
 • By default, discrete probability distributions assume only integer values, but some distributions can also assume non-integer values. One way to achieve this is to use the EmpiricalDistribution - currently the only pre-defined distribution that can be made to have non-integer values.
 • The other way to use discrete distributions that assume non-integer values is define them using the Distribution command with the option Type = discrete and specify a value for Support and DiscreteValueMap. This will be the subject of the remainder of this help page.
 • For this approach, Maple needs a way to generate the values that the distribution can assume. This is provided by the Support and DiscreteValueMap arguments. In particular, Support specifies a range of integers, and DiscreteValueMap specifies a mapping, so that applying DiscreteValueMap to this range of integers yields all possible values of the distribution.
 • For example, consider the distribution that assumes value $\frac{1}{3}$ with probability $\frac{1}{2}$, value $\frac{1}{9}$ with probability $\frac{1}{4}$, and generally value ${3}^{-n}$ with probability ${2}^{-n}$ for positive integers $n$. (These probabilities sum to 1, which is necessary for it to be a valid distribution.) We could specify these values as $\mathrm{Support}=1..\mathrm{\infty }$, $\mathrm{DiscreteValueMap}=\left(n↦{3}^{-n}\right)$.
 • For technical reasons, correct results for Maple's calculations can only be guaranteed if DiscreteValueMap is either strictly ascending or strictly descending. (As a consequence, it is impossible to, for example, specify a set of values that are dense in an open interval.)
 • When used as a separate command, using the calling sequences shown above, DiscreteValueMap evaluates the discrete value map of the given random variable at the parameter $n$. If the DiscreteValueMap is not defined for this random variable, DiscreteValueMap returns FAIL.
 • Apart from specifying these values, we will still need to specify the probabilities. These are typically given by specifying the ProbabilityFunction.
 • The ProbabilityFunction can have nonzero values at values outside the Support generated values; these nonzero values are ignored. This is also true for distributions assuming only integer values; for example, the GeometricDistribution has a ProbabilityFunction equal to $n↦\left\{\begin{array}{cc}0& n<0\\ p\cdot {\left(1-p\right)}^{n}& \mathrm{otherwise}\end{array}\right\$. This is nonzero for, for example, $n=\frac{3}{2}$, but this value is ignored. Similarly, when a DiscreteValueMap is given, then the ProbabilityFunction can be nonzero outside images of the DiscreteValueMap - that is, at values the distribution cannot actually assume. The reasons will be illustrated by the continued example from above.
 • In the previous example, we would specify $\mathrm{ProbabilityFunction}=\left(t↦\left\{\begin{array}{cc}0& t\le 0\\ {2}^{{\mathrm{log}}_{3}\left(t\right)}& t\le \frac{1}{3}\\ 0& \mathrm{otherwise}\end{array}\right\\right)$. It would be cumbersome to specify a probability function that is nonzero only at negative powers of 3; but we do not need to, since only the values at images of the DiscreteValueMap are relevant.

Examples

The example described in the text above looks like this:

 > $\mathrm{with}\left(\mathrm{Statistics}\right):$
 > $\mathrm{pf}≔t→\mathrm{piecewise}\left(t\le 0,0,t<1,{2}^{{\mathrm{log}}_{3}\left(t\right)},0\right)$
 ${\mathrm{pf}}{≔}{t}{↦}\left\{\begin{array}{cc}{0}& {t}{\le }{0}\\ {{2}}^{{{\mathrm{log}}}_{{3}}{}\left({t}\right)}& {t}{<}{1}\\ {0}& {\mathrm{otherwise}}\end{array}\right\$ (1)
 > $\mathrm{dist}≔\mathrm{Distribution}\left('\mathrm{ProbabilityFunction}'=\mathrm{pf},'\mathrm{Support}'=1..\mathrm{∞},'\mathrm{DiscreteValueMap}'=\left(n→{3}^{-n}\right),'\mathrm{Type}=\mathrm{discrete}'\right)$
 ${\mathrm{dist}}{≔}{\mathbf{module}}\left({}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{option}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{Distribution}}{,}{\mathrm{Discrete}}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{export}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{Support}}{,}{\mathrm{ProbabilityFunction}}{,}{\mathrm{Conditions}}{,}{\mathrm{DiscreteValueMap}}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end module}}$ (2)
 > $\mathrm{Mean}\left(\mathrm{dist}\right)$
 $\frac{{1}}{{5}}$ (3)
 > $\mathrm{sort}\left(\mathrm{Tally}\left(\mathrm{Sample}\left(\mathrm{dist},1000\right)\right)\right)$
 $\left[{0.0000169350878084303}{=}{1}{,}{0.0000508052634252909}{=}{1}{,}{0.000152415790275873}{=}{2}{,}{0.000457247370827618}{=}{6}{,}{0.00137174211248285}{=}{13}{,}{0.00411522633744856}{=}{32}{,}{0.0123456790123457}{=}{73}{,}{0.0370370370370370}{=}{123}{,}{0.111111111111111}{=}{255}{,}{0.333333333333333}{=}{494}\right]$ (4)
 > $\mathrm{DiscreteValueMap}\left(\mathrm{dist},n\right)$
 ${{3}}^{{-}{n}}$ (5)

The normal distribution is continuous; it does not have a DiscreteValueMap. The geometric distribution is discrete, but it necessarily assumes integer values, so it also does not have a DiscreteValueMap.

 > $\mathrm{DiscreteValueMap}\left(\mathrm{Normal}\left(0,1\right),n\right)$
 ${\mathrm{FAIL}}$ (6)
 > $\mathrm{DiscreteValueMap}\left(\mathrm{RandomVariable}\left(\mathrm{Geometric}\left(\frac{1}{3}\right)\right),n\right)$
 ${\mathrm{FAIL}}$ (7)

The EmpiricalDistribution does have a DiscreteValueMap. It enumerates the values in sorted order.

 > $X≔\mathrm{RandomVariable}\left(\mathrm{EmpiricalDistribution}\left(\left[1,\mathrm{Pi},2,\sqrt{2},-5\right]\right)\right)$
 ${X}{≔}{\mathrm{_R4}}$ (8)
 > $\mathrm{DiscreteValueMap}\left(X,n\right)$
 ${\left[{-5}{,}{1}{,}\sqrt{{2}}{,}{2}{,}{\mathrm{\pi }}\right]}_{{n}}$ (9)
 > $\mathrm{DiscreteValueMap}\left(X,3\right)$
 $\sqrt{{2}}$ (10)

Compatibility

 • The Statistics[DiscreteValueMap] command was introduced in Maple 16.