Learn R Programming

distr (version 2.9.5)

liesInSupport: Generic Function for Testing the Support of a Distribution

Description

The function tests if x lies in the support of the distribution object.

Usage

liesInSupport(object, x, ...)
# S4 method for UnivarLebDecDistribution,numeric
liesInSupport(object,x, checkFin = FALSE)
# S4 method for UnivarMixingDistribution,numeric
liesInSupport(object,x, checkFin = FALSE)
# S4 method for LatticeDistribution,numeric
liesInSupport(object,x, checkFin = FALSE)
# S4 method for DiscreteDistribution,numeric
liesInSupport(object,x, checkFin = FALSE)
# S4 method for AbscontDistribution,numeric
liesInSupport(object,x, checkFin = FALSE)
# S4 method for Distribution,matrix
liesInSupport(object,x, checkFin = FALSE)
# S4 method for ExpOrGammaOrChisq,numeric
liesInSupport(object,x, checkFin = TRUE)
# S4 method for Lnorm,numeric
liesInSupport(object,x, checkFin = TRUE)
# S4 method for Fd,numeric
liesInSupport(object,x, checkFin = TRUE)
# S4 method for Norm,numeric
liesInSupport(object,x, checkFin = TRUE)
# S4 method for DExp,numeric
liesInSupport(object,x, checkFin = TRUE)
# S4 method for Cauchy,numeric
liesInSupport(object,x, checkFin = TRUE)
# S4 method for Td,numeric
liesInSupport(object,x, checkFin = TRUE)
# S4 method for Logis,numeric
liesInSupport(object,x, checkFin = TRUE)
# S4 method for Weibull,numeric
liesInSupport(object,x, checkFin = TRUE)
# S4 method for Unif,numeric
liesInSupport(object,x, checkFin = TRUE)
# S4 method for Beta,numeric
liesInSupport(object,x, checkFin = TRUE)

Value

logical vector

Arguments

object

object of class "Distribution"

x

numeric vector or matrix

checkFin

logical: in case FALSE, we simply check whether x lies in the numerical (i.e., possibly cut to relevant quantile range) support; in case TRUE we try to check this by more exact techniques (e.g. in case of lattice distributions) and by using slot .finSupport / the return values of q.l(object) in 0 and 1. This is only used on discrete (parts of) distributions).

...

used for specific arguments to particular methods.

Methods

object = "DiscreteDistribution", x = "numeric":

We return a logical vector of the same length as x with TRUE when x lies in the support of object. As support we use the value of support(object), so this is possibly cut to relevant quantile ranges. In case checkFin is TRUE, in addition, we flag those coordinates to TRUE where x < min(support(object)) if is.na(object@.finSupport[1]) or object@.finSupport[1]==FALSE or q.l(object)(0)==-Inf, and similarly, where x > max(support(object)) if is.na(object@.finSupport[2]) or object@.finSupport[2]==FALSE or q.l(object)(1)==Inf. In addition we flag those coordinates to TRUE where q.l(object)(0)<=x<min(support(object)) if object@.finSupport[1]==TRUE and, similarly, where q.l(object)(1)>=x>max(support(object)) if object@.finSupport[2]==TRUE.

object = "Distribution", x = "matrix":

Argument x is cast to vector and then the respective liesInSupport method for vectors is called. The method throws an arror when the dispatch mechanism does not find a suitable, applicable respective vector-method.

object = "AbscontDistribution", x = "numeric":

We return a logical vector of the same length as x with TRUE where q.l(object)(0)<=x<=q.l(object)(1) (and replace the boundary values by q.l(object)(10*.Machine$double.eps) resp. q.l(object)(1-10*.Machine$double.eps) once the return values for 0 or 1 return are NaN.

object = "LatticeDistribution", x = "numeric":

We return a logical vector of the same length as x with TRUE when x lies in the support of object. As support we use the value of support(object), so this is possibly cut to relevant quantile ranges. In case checkFin is TRUE, we instead use the lattice information: We check whether all values (x-pivot(lattice(object))/width(lattice(object)) are non-negative integers and are non larger than Length(lattice(object))-1. In addition, we flag those coordinates to TRUE where x < min(support(object)) if is.na(object@.finSupport[1]) or object@.finSupport[1]==FALSE, and similarly, where x > max(support(object)) if is.na(object@.finSupport[2]) or object@.finSupport[2]==FALSE.

object = "UnivarLebDecDistribution", x = "numeric":

We split up object into discrete and absolutely continuous part and for each of them apply liesInSupport separately; the two return values are combined by a coponentwise logical |.

object = "UnivarMixingDistribution", x = "numeric":

We first cast object to UnivarLebDecDistribution by flat.mix and then apply the respective method.

Author

Matthias Kohl Matthias.Kohl@stamats.de and Peter Ruckdeschel peter.ruckdeschel@uni-oldenburg.de

See Also

Distribution-class

Examples

Run this code
liesInSupport(Exp(1), rnorm(10))

# note
x <- rpois(10, lambda = 10)
liesInSupport(Pois(1), x)
# better
liesInSupport(Pois(1), x, checkFin = TRUE)
liesInSupport(Pois(1), 1000*x, checkFin = TRUE)
liesInSupport(-10*Pois(1), -10*x+1, checkFin = TRUE)

xs = c(1000*x,runif(10))
D <- UnivarMixingDistribution(Pois(1),Unif())
liesInSupport(D, xs)

Run the code above in your browser using DataLab