Description Usage Arguments Author(s) See Also Examples
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.
1 | csum_N(pmf, support, lambda, eps = 1e-05)
|
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 |
An integer vector from 0 to the largest element of the
pmf's support. |
lambda |
A number > 0. |
eps |
A number in (0, 1); |
Junkyu Park
dpmf
,
rpmf
,
Evaluating a hard-to-evaluate pmf using pgf and DFT
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.