csum_N: csum_N

Description Usage Arguments Author(s) See Also Examples

Description

Using the Discrete Fourier Transform, return the approximate pmf vector of S = sum of iid X_i's, i = 1, ..., N, where N ~ Pois(lambda) and N is independent of all X_i's.

Usage

1
csum_N(pmf, support, lambda, eps = 1e-05)

Arguments

pmf

A probability mass function of X_i which takes elements of an ambient space of pmf's support (i.e. an input that makes pmf return a probability) in its first argument. This pmf must have a finite support, and be able to take an array of elements and return an array of probabilities. Each output of this pmf must fall in [0, 1], and every conceivable output, including 0, must sum up to 1, i.e. if an object that is not an element of support is given, pmf must return 0.

support

An integer vector from 0 to the largest element of the pmf's support. support (of X_i) consists of nonnegative integers.

lambda

A number > 0.

eps

A number in (0, 1); 1e-05 by default

Author(s)

Junkyu Park

See Also

dpmf, rpmf, Evaluating a hard-to-evaluate pmf using pgf and DFT

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Example 1: S_Y = sum of iid Y_i's, Y_i ~ dY
dY <- function(y) {
    sapply(
        y,
        function(d) {
            if (d %in% c(1, 4)) {
                .25
            } else if (d == 2) {
                .5
            } else {
                0
            }
        }
    )
}
result_Y <- csum_N(dY, support = 0:4, lambda = 3)
# Example 2: S = sum of iid X_i's, X_i ~ dX
dX <- function(x) {
    sapply(
        x,
        function(d) {
            if (d == 0) {
                .05
            } else if (d %in% c(1, 3, 4)) {
                .1
            } else if (d == 2) {
                .075
            } else if (d == 5) {
                .575
            } else {
                0
            }
        }
    )
}
result_X <- csum_N(dX, support = 0:5, lambda = 3)

joon3216/funpark documentation built on June 18, 2019, 7:32 a.m.