dpmf: dpmf

Description Usage Arguments Author(s) See Also Examples

Description

Create a probability mass function.

Usage

1
dpmf(x, pmf_vec, support_vec)

Arguments

x

A number, or a vector whose class is the same as support_vec

pmf_vec

A numeric vector, where each element falls in [0, 1] and sums up to 1

support_vec

A vector with the same length as pmf_vec where each entry of support_vec is the input that corresponds to the probability in pmf_vec; if missing, it is replaced with 0:(length(pmf_vec) - 1).

Author(s)

Junkyu Park

See Also

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

Examples

1
2
3
4
5
6
7
8
# Example 1: dfruit
dfruit <- function(x){
    unname(dpmf(x, c(.25, .4, .35), c('apple', 'orange', 'neither')))
}
dfruit(c('apple', 'neither', 'pineapple'))
# Example 2: dbinom with size = 2 and prob = .5
dbinom2 <- function(x){dpmf(x, c(.25, .5, .25), 0:2)}
dbinom2(-2:3)

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