distr (version 2.3.1)

LatticeDistribution-class: Class "LatticeDistribution"

Description

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.

Arguments

Objects from the Class

The usual way to generate objects of class LatticeDistribution is to call the generating function LatticeDistribution. 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.

Extends

Class "UnivariateDistribution", directly. Class "Distribution", by class "UnivariateDistribution".

concept

  • discrete distribution
  • lattice distribution
  • lattice of a distribution
  • S4 distribution class
  • generating function

See Also

LatticeDistribution 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.d

Examples

Run this code
B <- 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 DataCamp Workspace