distrEx (version 0.4-3)

var: Generic Function for the Computation of Functionals

Description

Generic function for the computation of functionals on distributions.

Usage

IQR(x, ...)

## S3 method for class 'UnivariateDistribution':
IQR(x)

median(x, ...)

## S3 method for class 'UnivariateDistribution':
median(x)

mad(x, ...)

## S3 method for class 'UnivariateDistribution':
mad(x)

sd(x, ...)

## S3 method for class 'UnivariateDistribution':
sd(x, fun, cond, withCond, useApply, ...)

var(x, ...)

## S3 method for class 'UnivariateDistribution':
var(x, fun, cond, withCond, useApply, ...)
## S3 method for class 'Binom':
var(x)
## S3 method for class 'Beta':
var(x)
## S3 method for class 'Cauchy':
var(x)
## S3 method for class 'Chisq':
var(x)
## S3 method for class 'Dirac':
var(x)
## S3 method for class 'Exp':
var(x)
## S3 method for class 'Fd':
var(x)
## S3 method for class 'Gammad':
var(x)
## S3 method for class 'Geom':
var(x)
## S3 method for class 'Hyper':
var(x)
## S3 method for class 'Logis':
var(x)
## S3 method for class 'Lnorm':
var(x)
## S3 method for class 'Nbinom':
var(x)
## S3 method for class 'Norm':
var(x)
## S3 method for class 'Pois':
var(x)
## S3 method for class 'Td':
var(x)
## S3 method for class 'Unif':
var(x)
## S3 method for class 'Weibull':
var(x)

Arguments

x
object of class "UnivariateDistribution"
fun
if missing the (conditional) variance resp. standard deviation is computed else the (conditional) variance resp. standard deviation of fun is computed.
cond
if not missing the conditional variance resp. standard deviation given cond is computed.
...
additional arguments to fun or E
useApply
logical: should sapply, respectively apply be used to evaluate fund.
withCond
logical: is cond in the argument list of fun.

Value

  • The value of the corresponding functional at the distribution in the argument is computed.

concept

  • functional
  • var
  • sd
  • IQR
  • mad
  • median

See Also

distrExIntegrate, m1df, m2df, Distribution-class, sd, var, IQR, median, mad, sd

Examples

Run this code
# Variance of Exp(1) distribution
var(Exp())

#median(Exp())
IQR(Exp())
mad(Exp())

# Variance of N(1,4)^2
var(Norm(mean=1, sd=2), fun = function(x){x^2})
var(Norm(mean=1, sd=2), fun = function(x){x^2}, useApply = FALSE)

## sd -- may equivalently be replaced by var
sd(Pois()) ## uses explicit terms
sd(as(Pois(),"DiscreteDistribution")) ## uses sums
sd(as(Pois(),"UnivariateDistribution")) ## uses simulations
sd(Norm(mean=2), fun = function(x){2*x^2}) ## uses simulations
#
mad(sin(exp(Norm()+2*Pois()))) ## weird

Run the code above in your browser using DataCamp Workspace