DiscreteDistribution-class {distr}R Documentation

Class "DiscreteDistribution"

Description

The DiscreteDistribution-class is the mother-class of the class LatticeDistribution.

Usage

  DiscreteDistribution(supp, prob, .withArith=FALSE, .withSim=FALSE)
  DiscreteDistribution(supp)

Arguments

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.

Details

If prob is missing, all elements in supp are equally weighted.

Value

Object of class "DiscreteDistribution"

Objects from the Class

Objects can be created by calls of the generating function "DiscreteDistribution". This generating function, from version 1.9 on, has been moved to this package from package distrEx.

Slots

img:
Object of class "Reals": the space of the image of this distribution which has dimension 1 and the name "Real Space"
param:
Object of class "Parameter": the parameter of this distribution, having only the slot name "Parameter of a discrete distribution"
r:
Object of class "function": generates random numbers
d:
Object of class "function": density/probability function
p:
Object of class "function": cumulative distribution function
q:
Object of class "function": quantile function
.withArith:
logical: used internally to issue warnings as to interpretation of arithmetics
.withSim:
logical: used internally to issue warnings as to accuracy
support:
Object of class "numeric": a (sorted) vector containing the support of the discrete density function

Extends

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

Methods

initialize
signature(.Object = "DiscreteDistribution"): initialize method
Math
signature(x = "DiscreteDistribution"): application of a mathematical function, e.g. sin or exp (does not work with log!), to this discrete distribution
-
signature(e1 = "DiscreteDistribution"): application of `-' to this discrete distribution
*
signature(e1 = "DiscreteDistribution", e2 = "numeric"): multiplication of this discrete distribution by an object of class `numeric'
/
signature(e1 = "DiscreteDistribution", e2 = "numeric"): division of this discrete distribution by an object of class `numeric'
+
signature(e1 = "DiscreteDistribution", e2 = "numeric"): addition of this discrete distribution to an object of class `numeric'
-
signature(e1 = "DiscreteDistribution", e2 = "numeric"): subtraction of an object of class `numeric' from this discrete distribution
*
signature(e1 = "numeric", e2 = "DiscreteDistribution"): multiplication of this discrete distribution by an object of class `numeric'
+
signature(e1 = "numeric", e2 = "DiscreteDistribution"): addition of this discrete distribution to an object of class `numeric'
-
signature(e1 = "numeric", e2 = "DiscreteDistribution"): subtraction of this discrete distribution from an object of class `numeric'
+
signature(e1 = "DiscreteDistribution", e2 = "DiscreteDistribution"): Convolution of two discrete distributions. The slots p, d and q are approximated on a common grid.
-
signature(e1 = "DiscreteDistribution", e2 = "DiscreteDistribution"): Convolution of two discrete distributions. The slots p, d and q are approximated on a common grid.
support
signature(object = "DiscreteDistribution"): returns the support
p.l
signature(object = "DiscreteDistribution"): returns the left continuous cumulative distribution function, i.e.; p.l(t) = P(object < t)
q.r
signature(object = "DiscreteDistribution"): returns the right-continuous quantile function, i.e.; q.r(s)=sup{t|P(object>=t)<=s}
plot
signature(object = "DiscreteDistribution"): plots density, cumulative distribution and quantile function

Internal subclass "AffLinDiscreteDistribution"

To enhance accuracy of several functionals on distributions, mainly from package distrEx, from version 1.9 of this package on, there is an internally used (but exported) subclass "AffLinDiscreteDistribution" which has extra slots a, b (both of class "numeric"), and X0 (of class "DiscreteDistribution"), 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

There also is a class union of "AffLinAbscontDistribution" and "AffLinDiscreteDistribution" called "AffLinDistribution" which is used for functionals.

Note

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

Author(s)

Thomas Stabla statho3@web.de,
Florian Camphausen fcampi@gmx.de,
Peter Ruckdeschel Peter.Ruckdeschel@uni-bayreuth.de,
Matthias Kohl Matthias.Kohl@stamats.de

See Also

Parameter-class UnivariateDistribution-class LatticeDistribution-class AbscontDistribution-class Reals-class RtoDPQ.d

Examples

# Dirac-measure at 0
D1 <- DiscreteDistribution(supp = 0)
support(D1)

# simple discrete distribution
D2 <- DiscreteDistribution(supp = c(1:5), prob = c(0.1, 0.2, 0.3, 0.2, 0.2))
plot(D2)
(pp <- p(D2)(support(D2)))
p(D2)(support(D2)-1e-5)
p(D2)(support(D2)+1e-5)
p.l(D2)(support(D2))
p.l(D2)(support(D2)-1e-5)
p.l(D2)(support(D2)+1e-5)
q(D2)(pp)
q(D2)(pp-1e-5)
q(D2)(pp+1e-5)
q.r(D2)(pp)
q.r(D2)(pp-1e-5)
q.r(D2)(pp+1e-5)

[Package distr version 1.9 Index]