cfE_EmpiricalOgive: Characteristic function of the Ogive empirical distribution...

View source: R/cfE_EmpiricalOgive.R

cfE_EmpiricalOgiveR Documentation

Characteristic function of the Ogive empirical distribution based on the observed histogram

Description

cfE_EmpiricalOgive(t, bins, freq) calculates characteristic function of the Ogive empirical distribution based on the observed histogram (given by bins and frequencies). That is, cf(t) is given as a weighted mixture of the UNIFORM iid RVs.

cf(t) = cfE_EmpiricalOgive(t,bins,freq) = sum_{j=1}^n freq_j * cf_Uniform(t,bins_{j-1},bins_{j}),

where cf_Uniform(t,bin_{j-1},bin_{j}) is CF of the Uniform distribution on the interval [bins_{j-1},bins_j].

The bins and frequencies = counts/sum(counts) are based on the discretized/grouped or histogram data, for more details see e.g. the R function hist.

Usage

cfE_EmpiricalOgive(t, bins, freq)

Arguments

t

vector or array of real values, where the CF is evaluated.

bins

vector of breaks of histogram bins.

freq

frequencies for each bin of histogram.

Value

Characteristic function cf(t) of the EMPIRICAL distribution, based on the observed data.

Note

Ver.: 02-Oct-2018 14:07:43 (consistent with Matlab CharFunTool v1.3.0, 24-Jun-2017 09:34:15).

References

WITKOVSKY V., WIMMER G., DUBY T. (2017). Computing the aggregate loss distribution based on numerical inversion of the compound empirical characteristic function of frequency and severity. arXiv preprint arXiv:1701.08299.

See Also

For more details see WIKIPEDIA: https://en.wikipedia.org/wiki/Empirical_characteristic_function.

Other Empirical Probability Distribution: cfE_DiracMixture(), cfE_Empirical()

Examples

## EXAMPLE1 (Ogive ECF - a weighted mixture of independent Uniform RVs)
set.seed(101)
n <- 1000
Data <- c(rnorm(3 * n, 5, 0.2), rt(n, 10))
Edges <- -6:6
Counts <- hist(x = Data, breaks = Edges)$counts
Xbins <- Edges
Xfreq <- Counts / sum(Counts)
t <- seq(-10, 10, length.out = 501)
bins <- Xbins
freq <- Xfreq
plotReIm(function(t) cfE_EmpiricalOgive(t, Xbins, Xfreq),
         t, title = 'Ogive ECF of the grouped (histogram) data')

## EXAMPLE2 (PDF/CDF of the Ogive distribution)
set.seed(101)
n <- 1000
Data <- c(rnorm(3 * n, 5, 0.2), rt(n, 10))
Edges <- -6:6
Counts <- hist(x = Data, breaks = Edges)$counts
Xbins <- Edges
Xfreq <- Counts / sum(Counts)
cf <- function(t) cfE_EmpiricalOgive(t, Xbins, Xfreq)
x <- seq(-5, 7, length.out = 101)
prob <- c(0.9, 0.95)
options <- list()
options$N <- 2^12
options$SixSigmaRule <- 8
result <- cf2DistGP(cf, x, prob, options)

## EXAMPLE3 (PDF/CDF of the compound Poisson-Ogive distribution)
set.seed(101)
n <- 1000
Data <- c(rnorm(3 * n, 5, 0.2), rt(n, 10))
Edges <- -6:6
Counts <- hist(x = Data, breaks = Edges)$counts
Xbins <- Edges
Xfreq <- Counts / sum(Counts)
cfX <- function(t) cfE_EmpiricalOgive(t, Xbins, Xfreq)
lambda <- 15
cf <- function(t) cfN_Poisson(t, lambda, cfX)
x <- seq(0, 100, length.out = 101)
prob <- c(0.9, 0.95, 0.99)
options <- list()
options$isCompound <- TRUE
result <- cf2DistGP(cf, x, prob, options)

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