Learn R Programming

descriptr (version 0.1.0)

binom_plot: Visualize Binomial Distribution

Description

Visualize how changes in number of trials and the probability of success affect the shape of the binomial distribution. compute\/visualize probability from a given quantile and quantiles out of given probability.

Usage

binom_plot(n, p)

binom_prob(n, p, s, type = c("lower", "upper", "exact", "interval"))

binom_perc(n, p, tp, type = c("lower", "upper"))

Arguments

n

number of trials

p

aggregate probability

s

number of success

type

lower/upper/exact/interval

tp

the probability of success in a trial

Value

a list containing the following components:

avg

mean of the binomial distribution

stdev

standard deviation of the binomial distribution

prob

probability of s success

See Also

Binomial

Examples

Run this code
# visualize binomial distribution
binom_plot(10, 0.3)

# compute\/visualize probability from a given quantile
binom_prob(10, 0.3, 4, type = 'exact')
binom_prob(10, 0.3, 4, type = 'lower')
binom_prob(10, 0.3, 4, type = 'upper')
binom_prob(10, 0.3, c(4, 6), type = 'interval')

# compute\/visualize quantiles out of given probability
binom_perc(10, 0.5, 0.05)
binom_perc(10, 0.5, 0.05, "upper")

Run the code above in your browser using DataLab