# Define the parameters
x <- 11 # number of successes
n <- 40 # number of trials
p <- 0.6 # hypothesized probability of success
# Perform the binomial test
binom.test (x, n, p, alternative = "two.sided")
##
## Exact binomial test
##
## data: x and n
## number of successes = 11, number of trials = 40, p-value = 6.018e-05
## alternative hypothesis: true probability of success is not equal to 0.6
## 95 percent confidence interval:
## 0.1460090 0.4388829
## sample estimates:
## probability of success
## 0.275
# Define the mean value
lambda <- 4 * 300 / 100
# the probability of zero typos
dpois(0, lambda)
## [1] 6.144212e-06
# more than five
# Define the mean value
lambda <- 4 * 300 / 100
1- ppois(6, lambda)
## [1] 0.9541777
# book of 157 pages has no typos
# Define the mean value
lambda <- 4 * 157 / 100
dpois(0, lambda)
## [1] 0.001873401
# the probability there will be more than seven accidents
# Define the mean value
lambda <- 4
1- ppois(8, lambda)
## [1] 0.02136343
# not more than three accidents
# Define the mean value
lambda <- 4 * 2
ppois(4, lambda)
## [1] 0.0996324
# zero calls during one minute
# Define the mean value
lambda <- 2
dpois(0, lambda)
## [1] 0.1353353
# less than five calls in one minute
# Define the mean value
lambda <- 2
ppois(5, lambda)
## [1] 0.9834364
# less than six calls in one hour
# Define the mean value
lambda <- 2 * 60
ppois(6, lambda)
## [1] 3.345775e-43
# what percentage of the population lives in poverty
dnorm(10000, 25000, 10000) * 100
## [1] 0.001295176
# what percentage of the population will benefit from the new tax law
sum(dnorm(20000:30000, 25000, 10000) * 100)
## [1] 38.29601
# probability that light bulb lasts between 3 and 12 months
sum(dexp(3:12, 1/8))
## [1] 0.5216646
# the 95th percentile of the distribution
qexp(0.95, 1/8)
## [1] 23.96586
# probability bulbs that has lasted 10 months will last more than 25 months
1- pexp(36, 1/8)
## [1] 0.011109
# Define the shape parameters of the Beta distribution
alpha <- 4
beta <- 2
#mean
alpha / (alpha + beta)
## [1] 0.6666667
#variance
alpha * beta / ((alpha + beta)^2 * (alpha + beta + 1))
## [1] 0.03174603
#probability that at least 80% computers are sold
1 - pbeta(0.8, alpha, beta)
## [1] 0.26272