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.LatticeDistribution(DiscreteDistribution)
LatticeDistribution(lattice, DiscreteDistribution)
LatticeDistribution(lattice, supp, prob, .withArith, .withSim, check = FALSE)
LatticeDistribution(lattice, supp, prob)
LatticeDistribution(supp)DiscreteDistribution
or AffLinDiscreteDistribution to be
coerced to LatticeDistribution or AffLinLatticeDistribution,
respectivelyLattice) which determines the support
of the discrete distribution.supp.supp, prob distributional arithmetics was
involved, you may set this to TRUE.supp, prob simulations were involved, you may
set this to TRUE.TRUE, LatticeDistribution() throws an
error if argument lattice and other arguments are
inconsistent or if there is no way to automatically generate
a 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."UnivariateDistribution", directly.
Class "Distribution", by class "UnivariateDistribution"."AffLinLatticeDistribution" which has extra slots
a, b (both of class "numeric"), and X0
(of class "LatticeDistribution"), to capture the fact
that the object has the same distribution as a * X0 + b. This is
the class of the return value of methods
signature(e1 = "LatticeDistribution")}
signature(e1 = "LatticeDistribution", e2 = "numeric")}
signature(e1 = "LatticeDistribution", e2 = "numeric")}
signature(e1 = "LatticeDistribution", e2 = "numeric")}
signature(e1 = "LatticeDistribution", e2 = "numeric")}
signature(e1 = "numeric", e2 = "LatticeDistribution")}
signature(e1 = "numeric", e2 = "LatticeDistribution")}
signature(e1 = "numeric", e2 = "LatticeDistribution")}
signature(e1 = "AffLinLatticeDistribution")}
signature(e1 = "AffLinLatticeDistribution", e2 = "numeric")}
signature(e1 = "AffLinLatticeDistribution", e2 = "numeric")}
signature(e1 = "AffLinLatticeDistribution", e2 = "numeric")}
signature(e1 = "AffLinLatticeDistribution", e2 = "numeric")}
signature(e1 = "numeric", e2 = "AffLinLatticeDistribution")}
signature(e1 = "numeric", e2 = "AffLinLatticeDistribution")}
signature(e1 = "numeric", e2 = "AffLinLatticeDistribution")}"AffLinDoscreteDistribution"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 the 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.Parameter-class
Lattice-class
UnivariateDistribution-class
DiscreteDistribution-class
Binom-class
Dirac-class
Geom-class
Hyper-class
Nbinom-class
Pois-class
AbscontDistribution-class
Reals-class
RtoDPQ.dB <- Binom(prob = 0.1,size = 10) # B is a Binomial distribution w/ prob=0.1 and size=10.
P <- Pois(lambda = 1) # P is a Poisson distribution with lambda = 1.
D1 <- B+1 # a new Lattice distributions with exact slots d, p, q
D2 <- D1*3 # a new Lattice distributions with exact slots d, p, q
D3 <- B+P # a new Lattice distributions with approximated slots d, p, q
D4 <- D1+P # a new Lattice distributions with approximated slots d, p, q
support(D4) # the (approximated) support of this distribution is 1, 2, ..., 21
r(D4)(1) # one random number generated from this distribution, e.g. 4
d(D4)(1) # The (approximated) density for x=1 is 0.1282716.
p(D4)(1) # The (approximated) probability that x<=1 is 0.1282716.
q(D4)(.5) # The (approximated) 50 percent quantile is 3.Run the code above in your browser using DataLab