E {distrEx} | R Documentation |
Generic function for the computation of (conditional) expectations.
E(object, fun, cond, ...) ## S4 method for signature 'UnivariateDistribution, ## function, missing': E(object, fun, cond, useApply = TRUE, ...) ## S4 method for signature 'AbscontDistribution, function, ## missing': E(object, fun, cond, useApply = TRUE, ...) ## S4 method for signature 'DiscreteDistribution, function, ## missing': E(object, fun, cond, useApply = TRUE, ...) ## S4 method for signature 'AffLinDistribution, missing, ## missing': E(object, fun, cond) ## S4 method for signature 'AffLinUnivarLebDecDistribution, ## missing, missing': E(object, fun, cond) ## S4 method for signature 'MultivariateDistribution, ## function, missing': E(object, fun, cond, useApply = TRUE, ...) ## S4 method for signature 'DiscreteMVDistribution, ## function, missing': E(object, fun, cond, useApply = TRUE, ...) ## S4 method for signature 'AbscontCondDistribution, ## missing, numeric': E(object, fun, cond, useApply = TRUE) ## S4 method for signature 'DiscreteCondDistribution, ## missing, numeric': E(object, fun, cond, useApply = TRUE) ## S4 method for signature 'UnivariateCondDistribution, ## function, numeric': E(object, fun, cond, withCond = FALSE, useApply = TRUE, ...) ## S4 method for signature 'AbscontCondDistribution, ## function, numeric': E(object, fun, cond, withCond = FALSE, useApply = TRUE, ...) ## S4 method for signature 'DiscreteCondDistribution, ## function, numeric': E(object, fun, cond, withCond = FALSE, useApply = TRUE, ...) ## S4 method for signature 'DiscreteCondDistribution, ## function, numeric': E(object, fun, cond, withCond = FALSE, useApply = TRUE, ...) ## S4 method for signature 'Beta, missing, missing': E(object, fun, cond) ## S4 method for signature 'Binom, missing, missing': E(object, fun, cond) ## S4 method for signature 'Cauchy, missing, missing': E(object, fun, cond) ## S4 method for signature 'Chisq, missing, missing': E(object, fun, cond) ## S4 method for signature 'Dirac, missing, missing': E(object, fun, cond) ## S4 method for signature 'DExp, missing, missing': E(object, fun, cond) ## S4 method for signature 'Exp, missing, missing': E(object, fun, cond) ## S4 method for signature 'Fd, missing, missing': E(object, fun, cond) ## S4 method for signature 'Gammad, missing, missing': E(object, fun, cond) ## S4 method for signature 'Geom, missing, missing': E(object, fun, cond) ## S4 method for signature 'Hyper, missing, missing': E(object, fun, cond) ## S4 method for signature 'Logis, missing, missing': E(object, fun, cond) ## S4 method for signature 'Lnorm, missing, missing': E(object, fun, cond) ## S4 method for signature 'Nbinom, missing, missing': E(object, fun, cond) ## S4 method for signature 'Norm, missing, missing': E(object, fun, cond) ## S4 method for signature 'Pois, missing, missing': E(object, fun, cond) ## S4 method for signature 'Unif, missing, missing': E(object, fun, cond) ## S4 method for signature 'Td, missing, missing': E(object, fun, cond) ## S4 method for signature 'Weibull, missing, missing': E(object, fun, cond) ## S4 method for signature 'Arcsine, missing, missing': E(object, fun, cond)
object |
object of class "Distribution" |
fun |
if missing the (conditional) expectation is computed
else the (conditional) expection of fun is computed. |
cond |
if not missing the conditional expectation
given cond is computed. |
... |
additional arguments to fun |
useApply |
logical: should sapply , respectively apply
be used to evaluate fun . |
withCond |
logical: is cond in the argument list of fun . |
The precision of the computations can be controlled via
certain global options; cf. distrExOptions
.
The (conditional) expectation is computed.
distrExIntegrate
. support
and sum
.support
and sum
.X
either "DiscreteDistribution"
or "AbscontDistribution"
.
X
either "UnivarLebDecDistribution"
.
fun
under univariate distributions using
crude Monte-Carlo integration. fun
under univariate Lebesgue decomposed distributions
by separate calculations for discrete and absolutely continuous part. fun
under absolutely continuous
univariate distributions using distrExIntegrate
. fun
under discrete univariate
distributions using support
and sum
. fun
under discrete multivariate
distributions. The computation is based on support
and sum
. cond
.
The integral is computed using crude Monte-Carlo integration. cond
. The computation
is based on distrExIntegrate
. cond
. The computation is based
on support
and sum
. fun
under univariate conditional distributions
given cond
. The integral is computed using crude Monte-Carlo integration. fun
under absolutely continuous,
univariate conditional distributions given cond
. The
computation is based on distrExIntegrate
. fun
under discrete, univariate
conditional distributions given cond
. The computation is
based on support
and sum
. Matthias Kohl Matthias.Kohl@stamats.de and Peter Ruckdeschel peter.ruckdeschel@uni-bayreuth.de
distrExIntegrate
, m1df
, m2df
,
Distribution-class
# mean of Exp(1) distribution E <- Exp() E(E) ## uses explicit terms E(as(E,"AbscontDistribution")) ## uses numerical integration E(as(E,"UnivariateDistribution")) ## uses simulations E(E, fun = function(x){2*x^2}) ## uses simulations # the same operator for discrete distributions: P <- Pois(lambda=2) E(P) ## uses explicit terms E(as(P,"DiscreteDistribution")) ## uses sums E(as(P,"UnivariateDistribution")) ## uses simulations E(P, fun = function(x){2*x^2}) ## uses simulations # second moment of N(1,4) E(Norm(mean=1, sd=2), fun = function(x){x^2}) E(Norm(mean=1, sd=2), fun = function(x){x^2}, useApply = FALSE) # conditional distribution of a linear model D1 <- LMCondDistribution(theta = 1) E(D1, cond = 1) E(Norm(mean=1)) E(D1, function(x){x^2}, cond = 1) E(Norm(mean=1), fun = function(x){x^2}) E(D1, function(x, cond){cond*x^2}, cond = 2, withCond = TRUE, useApply = FALSE) E(Norm(mean=2), function(x){2*x^2}) # some Lebesgue decomposed distribution mymix <- UnivarLebDecDistribution(acPart = Norm(), discretePart = Binom(4,.4), acWeight = 0.4) E(mymix)