disc.mexp: Expected Values of Discrete Random Variables

Description Usage Arguments Value Examples

View source: R/ch6-fn.R

Description

Expected Values of Discrete Random Variables

Usage

1
2
disc.mexp(xv, fx, fx2, fx3, mt, dig = 3, del = 0.2, prt = TRUE,
  plot = TRUE)

Arguments

xv

Vector of random variable values

fx

List of probability distributions (2~9)

fx2

Second list of probability distributions (same number of fx)

fx3

Third list of probability distributions (same number of fx)

mt

Vector of plot titles

dig

Number of digits below decimal point, Default: 3

del

Distance between the probability distribution plots, Default: 0.2

prt

Print the expected values and variances? Default: TRUE

plot

Plot the probability distributions? Default: TRUE

Value

list(Ex, Vx, Dx)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Binomial distributions
n = 10;  p=c(0.2, 0.5, 0.8); x = 0:n
fx1 = fx2 = list()
for (i in 1:3) fx1[[i]] = dbinom(x, n, p[i])
mt1 = paste0("B(10,", p, ")")
disc.mexp(x, fx1, mt=mt1)
# Binomial vs. Hypergeometric
N = 50;  S =c(10, 25, 40); n = 10; x = 0:n
for (i in 1:3) fx2[[i]] = dhyper(x, S[i], N-S[i], n)
mt12 = paste0("HG(10,50,", S,"):B(10,", p,")")
disc.mexp(x, fx2, fx1, mt=mt12)

tjssu/Rstat documentation built on Aug. 8, 2020, 12:38 p.m.