cf_Conv: Characteristic function of a linear combination (convolution)...

View source: R/cf_Conv.R

cf_ConvR Documentation

Characteristic function of a linear combination (convolution) of iid random variables X

Description

cf_Conv(t, cfX, coef, n) computes the characteristic function of a linear combination (convolution) of iid random variables X with given (common) characteristic function cfX(t) and the coefficients coef, and such that Y = coef(1)*X + ... + coef(N)*X, i.e. cf = cfX(coef(1)*t) * ... * cfX(coef(N)*t).

If or all coef == 1, then cf = cfX(t)^N, . Moreover, with using the optional parameter n, the algorithm evaluates CF of the convolution of n independent copies of the random variable Y, i.e. Z = Y + ... + Y, where Y = coef(1)*X + ... + coef(N)*X, i.e. cf = (cfX(coef(1)*t) * ... * cfX(coef(N)*t))^n.

Usage

cf_Conv(t, cfX, coef, n)

Arguments

t

vector (or array) of input values t where the cf_Conv is evaluated.

cfX

function handle to the given chracteristic function cfX(t).

coef

vector of coeficients of the linear combination of the iid random variables, such that Y = sum(coef(k) * X_k), cf = Prod_{k=1}^N cfX(coef(k)*t).

n

optional power coeficient of additional convolution of the combiend CF of Y. With using n (if empty, default value is n = 1), cf = (Prod_{k=1}^N cfX(coef(k)*t)^n.

Value

The characteristic function of a linear combination of iid RVs with characteristic function cf, evaluated at t.

Note

Ver.: 06-Oct-2018 18:14:22 (consistent with Matlab CharFunTool v1.3.0, 9-May-2017 10:22:48).

See Also

Other CF Tool: cfX_PDF()

Examples

## EXAMPLE 1
# CF of a linear combination of chi-square random variables
df <- 1
cfX <- function(t) cfX_ChiSquare(t, df)
coef <- 1 / (1:100)
cf <- function(t) cf_Conv(t, cfX, coef)
t <- seq(-10, 10, length.out = 501)
plotReIm(cf, t, title = 'CF of a Linear Combination of iid Chi-Square RVs')
options <- list()
options$xMin <- 0
result <- cf2DistGP(cf, options = options)

## EXAMPLE 2
# CF of a linear combination of iid RVs sampled from the empirical
# distribution function (atrtificially generated data)
n <- 30
p <- c(0.2, 0.7, 0.1)
data <- p[1] * rchisq(n, 5) + p[2] * rnorm(n, 10, 1) + p[3] * rt(n, 1)
cfE <- function(t) cfE_Empirical(t, data)
coef <- 1 / c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
cf <- function(t) cf_Conv(t, cfE, coef)
t <- seq(-10, 10, length.out = 501)
plotReIm(cf, t, title = 'CF of a Linear Combination of iid RVs')
result <- cf2DistGP(cf)

gajdosandrej/CharFunToolR documentation built on June 3, 2024, 7:46 p.m.