E

0th

Percentile

Generic Function for the Computation of (Conditional) Expectations

Generic function for the computation of (conditional) expectations.

Keywords
methods, distribution
Usage
E(object, fun, cond, ...)

## S3 method for class 'UnivariateDistribution,function,missing':
E(object, fun, cond, useApply = TRUE, ...)

## S3 method for class 'AbscontDistribution,function,missing':
E(object, fun, cond, useApply = TRUE, ...)

## S3 method for class 'DiscreteDistribution,function,missing':
E(object, fun, cond, useApply = TRUE, ...)

## S3 method for class 'AffLinDistribution,missing,missing':
E(object)

## S3 method for class 'MultivariateDistribution,function,missing':
E(object, fun, cond, useApply = TRUE, ...)

## S3 method for class 'DiscreteMVDistribution,function,missing':
E(object, fun, cond, useApply = TRUE, ...)

## S3 method for class 'AbscontCondDistribution,missing,numeric':
E(object, cond, useApply = TRUE)

## S3 method for class 'DiscreteCondDistribution,missing,numeric':
E(object, cond, useApply = TRUE)

## S3 method for class 'UnivariateCondDistribution,function,numeric':
E(object, fun, cond, withCond = FALSE, useApply = TRUE, ...)

## S3 method for class 'AbscontCondDistribution,function,numeric':
E(object, fun, cond, withCond = FALSE, useApply = TRUE, ...)

## S3 method for class 'DiscreteCondDistribution,function,numeric':
E(object, fun, cond, withCond = FALSE, useApply = TRUE, ...)

## S3 method for class 'DiscreteCondDistribution,function,numeric':
E(object, fun, cond, withCond = FALSE, useApply = TRUE, ...)

## S3 method for class 'Beta,missing,missing':
E(object, fun, cond)
## S3 method for class 'Binom,missing,missing':
E(object, fun, cond)
## S3 method for class 'Cauchy,missing,missing':
E(object, fun, cond)
## S3 method for class 'Chisq,missing,missing':
E(object, fun, cond)
## S3 method for class 'Dirac,missing,missing':
E(object, fun, cond)
## S3 method for class 'DExp,missing,missing':
E(object, fun, cond)
## S3 method for class 'Exp,missing,missing':
E(object, fun, cond)
## S3 method for class 'Fd,missing,missing':
E(object, fun, cond)
## S3 method for class 'Gammad,missing,missing':
E(object, fun, cond)
## S3 method for class 'Geom,missing,missing':
E(object, fun, cond)
## S3 method for class 'Hyper,missing,missing':
E(object, fun, cond)
## S3 method for class 'Logis,missing,missing':
E(object, fun, cond)
## S3 method for class 'Lnorm,missing,missing':
E(object, fun, cond)
## S3 method for class 'Nbinom,missing,missing':
E(object, fun, cond)
## S3 method for class 'Norm,missing,missing':
E(object, fun, cond)
## S3 method for class 'Pois,missing,missing':
E(object, fun, cond)
## S3 method for class 'Unif,missing,missing':
E(object, fun, cond)
## S3 method for class 'Td,missing,missing':
E(object, fun, cond)
## S3 method for class 'Weibull,missing,missing':
E(object, fun, cond)
Arguments
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.
Details

The precision of the computations can be controlled via certain global options; cf. distrExOptions.

Value

  • The (conditional) expectation is computed.

concept

  • expectation
  • conditional expectation
  • integration
  • functional
  • moment

See Also

distrExIntegrate, m1df, m2df, Distribution-class

Aliases
  • E
  • E-methods
  • E,UnivariateDistribution,missing,missing-method
  • E,AbscontDistribution,missing,missing-method
  • E,DiscreteDistribution,missing,missing-method
  • E,AffLinDistribution,missing,missing-method
  • E,AffLinAbscontDistribution,missing,missing-method
  • E,AffLinDiscreteDistribution,missing,missing-method
  • E,AffLinLatticeDistribution,missing,missing-method
  • E,MultivariateDistribution,missing,missing-method
  • E,DiscreteMVDistribution,missing,missing-method
  • E,UnivariateDistribution,function,missing-method
  • E,AbscontDistribution,function,missing-method
  • E,DiscreteDistribution,function,missing-method
  • E,MultivariateDistribution,function,missing-method
  • E,DiscreteMVDistribution,function,missing-method
  • E,UnivariateCondDistribution,missing,numeric-method
  • E,AbscontCondDistribution,missing,numeric-method
  • E,DiscreteCondDistribution,missing,numeric-method
  • E,UnivariateCondDistribution,function,numeric-method
  • E,AbscontCondDistribution,function,numeric-method
  • E,DiscreteCondDistribution,function,numeric-method
  • E,Beta,missing,missing-method
  • E,Binom,missing,missing-method
  • E,Cauchy,missing,missing-method
  • E,Chisq,missing,missing-method
  • E,Dirac,missing,missing-method
  • E,DExp,missing,missing-method
  • E,Exp,missing,missing-method
  • E,Fd,missing,missing-method
  • E,Gammad,missing,missing-method
  • E,Geom,missing,missing-method
  • E,Hyper,missing,missing-method
  • E,Logis,missing,missing-method
  • E,Lnorm,missing,missing-method
  • E,Nbinom,missing,missing-method
  • E,Norm,missing,missing-method
  • E,Pois,missing,missing-method
  • E,Td,missing,missing-method
  • E,Unif,missing,missing-method
  • E,Weibull,missing,missing-method
Examples
# 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})
Documentation reproduced from package distrEx, version 1.9, License: GPL (version 2 or later)

Community examples

Looks like there are no examples yet.