Edist: Expected value of a distribution

Description Usage Arguments Value Examples

Description

Calculate or approximate the expected value of a distribution. If support is missing, it is assumed that the support is continuous and integrate is used to approximate the expected value. If the support is countably infinite, then support should be chosen to reduce the error associated numerically approximating infinite sums.

Usage

1
Edist(dfunc, lower = -Inf, upper = Inf, support, ...)

Arguments

dfunc

Function that takes a random variable as its first argument and returns its probability (if support in not missing or probability density (if support is missing).

lower

Lower limit of the continuous support of the distribution (only has an effect if support is missing).

upper

Upper limit of the continuous support of the distribution (only has an effect if support is missing).

support

Values at which to evaluate a distribution with discrete support.

...

Additional arguments to pass to dfunc.

Value

The value of the expected value of dfunc (if support is not missing) or an approximation to the expected value supplied by integrate (if support is missing).

Examples

1
2
3
4
5
6
Edist(dnorm) # exactly 0
Edist(dpois, lambda = 1, support = 0:3) # bad approximation to 1
Edist(dpois, lambda = 1, support = 0:100) # (numerically) exactly 1
Edist(dbinom, size = 4, prob = 0.51, support = 0:4)
Edist(dgamma, lower = 0, shape = 2.3, scale = 0.2)
Edist(sin, lower = -1, upper = 1)

popmoments documentation built on May 2, 2019, 5 p.m.

Related to Edist in popmoments...