# LatticeDistribution

##### Class "LatticeDistribution"

The `LatticeDistribution`

-class is the mother-class of the
classes `Binom`

, `Dirac`

, `Geom`

, `Hyper`

, `Nbinom`

and
`Poisson`

. It formalizes a distribution on a regular affine
linear lattice.

- Keywords
- distribution

##### Usage

```
LatticeDistribution(lattice = NULL, supp = NULL, prob = NULL,
.withArith = FALSE, .withSim = FALSE,
DiscreteDistribution = NULL, check = TRUE,
Symmetry = NoSymmetry())
```

##### Arguments

- DiscreteDistribution
- an object of class
`DiscreteDistribution`

or`AffLinDiscreteDistribution`

to be coerced to`LatticeDistribution`

or`AffLinLatticeDistribution`

, respectively - lattice
- lattice (of class
`Lattice`

) which determines the support of the discrete distribution. - supp
- numeric vector which forms the support of the discrete distribution.
- prob
- vector of probability weights for the
elements of
`supp`

. - .withArith
- normally not set by the user, but if determining the entries
`supp`

,`prob`

distributional arithmetics was involved, you may set this to`TRUE`

. - .withSim
- normally not set by the user, but if determining the entries
`supp`

,`prob`

simulations were involved, you may set this to`TRUE`

. - check
- logical: if
`TRUE`

,`LatticeDistribution()`

throws an error if argument`lattice`

and other arguments are inconsistent or if there is no way to automatically generate a - Symmetry
- you may help Rin calculations if you tell it whether
the distribution is non-symmetric (default) or symmetric with respect
to a center; in this case use
`Symmetry=SphericalSymmetry(center)`

.

##### Details

Typical usages are
LatticeDistribution(DiscreteDistribution)
LatticeDistribution(lattice, DiscreteDistribution)
LatticeDistribution(lattice, supp, prob, .withArith, .withSim, check = FALSE)
LatticeDistribution(lattice, supp, prob)
LatticeDistribution(supp)
For the generating function `LatticeDistribution()`

, the arguments
are processed in the following order:
Arguments `.withSim`

and `.withArith`

are used in any case.
If there is an argument `DiscreteDistribution`

(of the respective class),
all its slots (except for `.withSim`

and `.withArith`

)
will be used for filling the slots of the object of class
`LatticeDistribution()`

/`AffLinLatticeDistribution()`

.
If in addition, there is an argument `lattice`

of class `Lattice`

,
it will be checked for consistency
with argument `DiscreteDistribution`

and if oK will be used for slot
lattice of the object of class
`LatticeDistribution()`

/`AffLinLatticeDistribution()`

. In case
there is no `lattice`

argument, slot `lattice`

will be constructed
from slot `support`

from argument `DiscreteDistribution`

.
If there is no argument `DiscreteDistribution`

, but there are arguments
`supp`

and `lattice`

(the latter of class `Lattice`

) then
these are checked for consistency and if oK, generating function
`DiscreteDistribution()`

is called with arguments `supp`

,
`prob`

, `.withArith`

, and `.withSim`

to produce an object
of class `DiscreteDistribution`

the slots of which will be used for the
filling the slots of the object of class
`LatticeDistribution()`

/`AffLinLatticeDistribution()`

.
If in this case, argument `prob`

is not given explicitely, all elements
in `supp`

are equally weighted.
If there is no argument `DiscreteDistribution`

, but there is an argument
`lattice`

of class `Lattice`

(but no argument `slot`

) then
if `Length(lattice)`

is finite, a corresponding support vector `supp`

is generated from argument `lattice`

and generating function
`DiscreteDistribution()`

is called with arguments `supp`

,
`prob`

, `.withArith`

, and `.withSim`

to produce an object
of class `DiscreteDistribution`

the slots of which will be used for the
filling the slots of the object of class `LatticeDistribution()`

.
If in the same situation `Length(lattice)`

is not finite, a finite length
for the support vector is extracted from argument `prob`

and after
generating `supp`

one procedes as in the finite `Length(lattice)`

case.
If there is no argument `DiscreteDistribution`

and no argument
`lattice`

of class `Lattice`

but an argument `supp`

then
it will be checked if `supp`

makes for a lattice, and if so,
`DiscreteDistribution()`

is called with arguments `supp`

,
`prob`

, `.withArith`

, and `.withSim`

to produce an object
of class `DiscreteDistribution`

the slots of which will be used for the
filling the slots of the object of class `LatticeDistribution()`

. The
corresponding `lattice`

-slot will be filled with information from
argument `supp`

.
The price for this flexibility of arguments, `LatticeDistribution()`

may
be called with, is that you should call `LatticeDistribution()`

with
*named arguments* only.
Note that internally we suppress lattice points from the support where
the probability is 0.

##### Note

Working with a computer, we use a finite interval as support which
carries at least mass `1-getdistrOption("TruncQuantile")`

.

##### Objects from the Class

The usual way to generate objects of class `LatticeDistribution`

is to call
the generating function `LatticeDistribution()`

(see details).
Somewhat more flexible, but also proner to inconsistencies is a call to
`new("LatticeDistribution")`

, where you may explicitly specify random
number generator, (counting) density, cumulative distribution and quantile
functions. For conveniance, in this call to `new("LatticeDistribution")`

,
an additional possibility is to only specify the random number generator. The
function `RtoDPQ.d`

then approximates the three remaining slots `d`

,
`p`

and `q`

by random sampling.

##### concept

- lattice distribution
- lattice of a distribution
- S4 distribution class
- generating function

##### See Also

`Parameter-class`

`Lattice-class`

`LatticeDistribution-class`

`Reals-class`

`RtoDPQ.d`

##### Examples

```
LatticeDistribution(DiscreteDistribution = DiscreteDistribution(supp =
c(4,3,2), prob=c(0.3,0.1,0.6)))
LatticeDistribution(supp = c(4,3,2))
```

*Documentation reproduced from package distr, version 2.2.3, License: LGPL-3*